Kill the correct buffer after sending a message

This commit is contained in:
2026-04-01 13:53:56 -07:00
parent e9e35a2635
commit a498c5a811

View File

@@ -326,24 +326,25 @@ This returns a hash table of cid -> path."
ARG is passed directly to `message-send'." ARG is passed directly to `message-send'."
;; This has to return a non-nil value so that org knows we handled the C-c C-c ;; This has to return a non-nil value so that org knows we handled the C-c C-c
(interactive "P") (interactive "P")
(let ((modified (buffer-modified-p)) (save-current-buffer
;; we only restore the restriction if the sending below fails (let ((modified (buffer-modified-p))
(old-rest (cons (point-min) (point-max)))) ;; we only restore the restriction if the sending below fails
(widen) (old-rest (cons (point-min) (point-max))))
(let ((save-text (buffer-substring-no-properties (point-min) (widen)
(point-max)))) (let ((save-text (buffer-substring-no-properties (point-min)
(condition-case _ (point-max))))
(progn (condition-case _
(when org-mu4e--html-message-p (progn
(org-mu4e--htmlize-and-cleanup)) (when org-mu4e--html-message-p
(message-send arg) (org-mu4e--htmlize-and-cleanup))
'sent) (message-send arg)
((or error quit) 'sent)
(erase-buffer) ((or error quit)
(insert save-text) (erase-buffer)
(narrow-to-region (car old-rest) (cdr old-rest)) (insert save-text)
(restore-buffer-modified-p modified) (narrow-to-region (car old-rest) (cdr old-rest))
'failed))))) (restore-buffer-modified-p modified)
'failed))))))
(defun org-mu4e-send-and-exit (&optional arg) (defun org-mu4e-send-and-exit (&optional arg)
"Call `org-mu4e-send', the save and kill the buffer. "Call `org-mu4e-send', the save and kill the buffer.