mu4e-compose: rework message-sent-hook

Grab the Fcc in the hook (when available).
This commit is contained in:
Dirk-Jan C. Binnema 2024-04-13 20:07:53 +03:00
parent a6ec43a740
commit 9f476295e1
1 changed files with 16 additions and 15 deletions

View File

@ -548,26 +548,27 @@ 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)
(let* ((fcc-path (message-fetch-field "Fcc"))) (when (eq mu4e-compose-type 'reply)
(when (eq mu4e-compose-type 'reply) (unless (message-fetch-field "In-Reply-To")
(unless (message-fetch-field "In-Reply-To") (message-remove-header "References")))
(message-remove-header "References"))) (when use-hard-newlines
(when use-hard-newlines (mu4e--send-harden-newlines))
(mu4e--send-harden-newlines)) ;; now handle what happens _after_ sending; typically, draft is gone and
;; now handle what happens _after_ sending; typically, draft is gone and ;; the sent message appears in sent. Update flags for related messages,
;; the sent message appears in sent. Update flags for related messages, ;; i.e. for Forwarded ('Passed') and Replied messages, try to set the
;; i.e. 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. (add-hook 'message-sent-hook
(add-hook 'message-sent-hook (lambda ()
(lambda () (save-restriction
(when fcc-path ;; hmmm... #2688 (message-narrow-to-headers)
(when-let ((fcc-path (message-fetch-field "Fcc")))
(mu4e--set-parent-flags fcc-path) (mu4e--set-parent-flags fcc-path)
;; we end up with a ((buried) buffer here, visiting ;; we end up with a ((buried) buffer here, visiting
;; the fcc-path; not quite sure why. But let's ;; the fcc-path; not quite sure why. But let's
;; get rid of it (#2681) ;; get rid of it (#2681)
(when-let ((buf (find-buffer-visiting fcc-path))) (when-let ((buf (find-buffer-visiting fcc-path)))
(kill-buffer buf)))) (kill-buffer buf)))))
nil t)))) nil t)))
;;; Crypto ;;; Crypto
(defun mu4e--compose-setup-crypto (parent compose-type) (defun mu4e--compose-setup-crypto (parent compose-type)