Skip to content

Commit

Permalink
[add] Predicate as `telega-chat-send-message-on-ret'
Browse files Browse the repository at this point in the history
Make it possible to use custom predicate to decide what should RET do

Fixes #465
  • Loading branch information
zevlg committed Mar 22, 2024
1 parent f5867ae commit 7df0fea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions telega-chat.el
Original file line number Diff line number Diff line change
Expand Up @@ -4499,9 +4499,10 @@ Behaviour depends on point position and value for
`telega-chat-send-message-on-ret'."
(interactive)
(if (or (eq 'always telega-chat-send-message-on-ret)
(eobp) ;point at the end of the prompt
(and (eq 'if-at-the-end-or-C-u telega-chat-send-message-on-ret)
current-prefix-arg))
(and (eq 'if-at-the-end telega-chat-send-message-on-ret)
(eobp))
(and (functionp telega-chat-send-message-on-ret)
(funcall telega-chat-send-message-on-ret)))
(call-interactively #'telega-chatbuf-input-send)
(call-interactively #'newline)))

Expand Down
7 changes: 4 additions & 3 deletions telega-customize.el
Original file line number Diff line number Diff line change
Expand Up @@ -1309,10 +1309,11 @@ Increasing this limit increases number of events telega needs to process."
"Customization for `\\<telega-chat-mode-map>\\[telega-chatbuf-newline-or-input-send]' behaviour."
:type '(choice
(const :tag "Always send a message" always)
;; NOTE: `if-at-the-end' is the same as #'eobp predicate
(const :tag "Send message if point at the end of prompt" if-at-the-end)
(const :tag "Send message if C-u is specified \
or point at the end of prompt" if-at-the-end-or-C-u))
:package-version '(telega . "0.8.121")
(function :tag "Predicate returning non-nil to send input"))
:package-version '(telega . "0.8.254")
:options '(eobp)
:group 'telega-chat)

(defcustom telega-chat-send-messages-async nil
Expand Down

0 comments on commit 7df0fea

Please sign in to comment.