From 933c1b0f7ac4efe1e7cd892ee6079b4a8acf406e Mon Sep 17 00:00:00 2001 From: Nicholas Vollmer Date: Thu, 10 Aug 2023 17:23:59 -0400 Subject: [PATCH] wip: add ement-room-compose-send-functions --- ement-room.el | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/ement-room.el b/ement-room.el index f8a0647a..f02246a7 100644 --- a/ement-room.el +++ b/ement-room.el @@ -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))) @@ -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