zevlg / telega.el

GNU Emacs telegram client (unofficial)
https://zevlg.github.io/telega.el/
GNU General Public License v3.0
1.09k stars 85 forks source link

add if-C-u as an option for telega-chat-send-message-on-ret #465

Closed macovsky closed 4 months ago

macovsky commented 4 months ago

it would be great if you could accept this option.

I'm used to sending messages with shift-enter in gui client because I tend to send multi-line text mostly and to keep in mind that enter works on (eobp) all the time is very tedious.

thanks!

zevlg commented 4 months ago

To keep bindings you are used to you might use this configuration:

(define-key telega-chat-mode-map (kbd "S-<return>") #'telega-chatbuf-input-send)
(define-key telega-chat-mode-map (kbd "<return>") #'newline)

in your telega-load-hook

As to PR, it looks good! However, I think it is better to introduce predicate as possible value for the telega-chat-send-message-on-ret and remove cludge if-at-the-end-or-C-u configuration option. Predicate will cover any usecases

macovsky commented 4 months ago

To keep bindings you are used to you might use this configuration:

(define-key telega-chat-mode-map (kbd "S-<return>") #'telega-chatbuf-input-send)
(define-key telega-chat-mode-map (kbd "<return>") #'newline)

in your telega-load-hook

that's awesome, thank you!

As to PR, it looks good! However, I think it is better to introduce predicate as possible value for the telega-chat-send-message-on-ret and remove cludge if-at-the-end-or-C-u configuration option. Predicate will cover any usecases

can you have a look? I'm not good at elisp so I might have done it badly

zevlg commented 4 months ago

Code needs a little cleanup, to avoid multiple if and code duplication. if-C-u is also should be covered by predicate setting instead, we should keep only always, if-at-the-end and predicate as value. If you don't mind I'll add this functionality myself?

macovsky commented 4 months ago

Code needs a little cleanup, to avoid multiple if and code duplication. if-C-u is also should be covered by predicate setting instead, we should keep only always, if-at-the-end and predicate as value. If you don't mind I'll add this functionality myself?

makes sense! for sure I don't, it's your project.

zevlg commented 4 months ago

Now you can (setq telega-chat-send-message-on-ret (lambda () current-prefix-arg)) to send message only if universal argument is used with RET.

macovsky commented 4 months ago

Now you can (setq telega-chat-send-message-on-ret (lambda () current-prefix-arg)) to send message only if universal argument is used with RET.

yay, thanks!