Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: add ement-room-compose-send-functions #200

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -3649,12 +3649,8 @@ To be called from a minibuffer opened from
(deactivate-input-method)
(abort-recursive-edit)))

(defun ement-room-compose-send ()
"Prompt to send the current compose buffer's contents.
To be called from an `ement-room-compose' buffer."
(interactive)
(cl-assert ement-room-compose-buffer)
(cl-assert ement-room) (cl-assert ement-session)
(defun ement-room--compose-send-default ()
"Send `ement-room-compose' contents to minibuffer."
;; Putting it in the kill ring seems like the best thing to do, to ensure
;; it doesn't get lost if the user exits the minibuffer before sending.
(kill-new (string-trim (buffer-string)))
Expand All @@ -3678,6 +3674,21 @@ To be called from an `ement-room-compose' buffer."
(ement-room-read-string prompt (car kill-ring) nil nil 'inherit-input-method)) ))
(ement-room-send-message ement-room ement-session :body body :replying-to-event replying-to-event))))

(defcustom ement-room-compose-send-functions '(ement-room--compose-send-default)
"Hook run in `ement-room-compose' buffer when `ement-room-compose-send' invoked."
:type 'hook)

(defun ement-room-compose-send ()
"Prompt to send the current compose buffer's contents.
To be called from an `ement-room-compose' buffer."
(interactive)
(cl-assert ement-room-compose-buffer)
(cl-assert ement-room) (cl-assert ement-session)
(let ((ement-room-compose-send-functions
;; Should we prevent nil hook binding here?
(or ement-room-compose-send-functions '(ement-room--compose-send-default))))
(run-hooks 'ement-room-compose-send-functions)))

(defun ement-room-init-compose-buffer (room session)
"Eval BODY, setting up the current buffer as a compose buffer.
Sets ROOM and SESSION buffer-locally, binds `save-buffer' in
Expand Down