mu4e-compose: update message sending

We no longer need the 'sent' handling; we can do it directly in
mu4e-compose, which simplifies things.
This commit is contained in:
Dirk-Jan C. Binnema 2024-04-09 23:51:45 +03:00
parent bc51989e65
commit 9a1b30b47e
1 changed files with 16 additions and 14 deletions

View File

@ -526,6 +526,9 @@ message buffer."
"Handler called with DOCID and PATH for the just-sent message. "Handler called with DOCID and PATH for the just-sent message.
For Forwarded ('Passed') and Replied messages, try to set the For Forwarded ('Passed') and Replied messages, try to set the
appropriate flag at the message forwarded or replied-to." appropriate flag at the message forwarded or replied-to."
;; XXX we don't need this function anymore here, but
;; we have an external caller in mu4e-icalendar... we should
;; update that.
(mu4e--set-parent-flags path) (mu4e--set-parent-flags path)
;; if the draft file exists, remove it now. ;; if the draft file exists, remove it now.
(when (file-exists-p path) (when (file-exists-p path)
@ -545,19 +548,19 @@ appropriate flag at the message forwarded or replied-to."
;; removing the In-Reply-To header. ;; removing the In-Reply-To header.
(save-restriction (save-restriction
(message-narrow-to-headers) (message-narrow-to-headers)
(when (eq mu4e-compose-type 'reply) (let* ((fcc-path (message-fetch-field "Fcc")))
(unless (message-fetch-field "In-Reply-To") (when (eq mu4e-compose-type 'reply)
(message-remove-header "References"))) (unless (message-fetch-field "In-Reply-To")
(when use-hard-newlines (message-remove-header "References")))
(mu4e--send-harden-newlines))) (when use-hard-newlines
;; for safety, always save the draft before sending (mu4e--send-harden-newlines))
(set-buffer-modified-p t) ;; now handle what happens _after_ sending; typically, draft is gone and
(save-buffer)) ;; the sent message appears in sent. Update flags for related messages,
;; i.e. for Forwarded ('Passed') and Replied messages, try to set the
(defun mu4e--compose-after-send () ;; appropriate flag at the message forwarded or replied-to.
"Function called just after sending a message." (add-hook 'message-sent-hook
(setq mu4e-sent-func #'mu4e-sent-handler) (lambda ()
(mu4e--server-sent (buffer-file-name))) (mu4e--set-parent-flags fcc-path)) nil t))))
;;; Crypto ;;; Crypto
(defun mu4e--compose-setup-crypto (parent compose-type) (defun mu4e--compose-setup-crypto (parent compose-type)
@ -823,7 +826,6 @@ replied to or forwarded, etc."
(add-hook 'before-save-hook #'mu4e--compose-before-save nil t) (add-hook 'before-save-hook #'mu4e--compose-before-save nil t)
(add-hook 'after-save-hook #'mu4e--compose-after-save nil t) (add-hook 'after-save-hook #'mu4e--compose-after-save nil t)
(add-hook 'message-send-hook #'mu4e--compose-before-send nil t) (add-hook 'message-send-hook #'mu4e--compose-before-send nil t)
(add-hook 'message-sent-hook #'mu4e--compose-after-send nil t)
(when-let ((fcc-path (mu4e--fcc-path (mu4e--message-basename) parent))) (when-let ((fcc-path (mu4e--fcc-path (mu4e--message-basename) parent)))
(message-add-header (concat "Fcc: " fcc-path "\n"))) (message-add-header (concat "Fcc: " fcc-path "\n")))