Skip to content

Commit

Permalink
mu4e-compose: rework message-sent-hook
Browse files Browse the repository at this point in the history
Grab the Fcc in the hook (when available).
  • Loading branch information
djcb committed Apr 14, 2024
1 parent a6ec43a commit 9f47629
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions mu4e/mu4e-compose.el
Original file line number Diff line number Diff line change
Expand Up @@ -548,26 +548,27 @@ appropriate flag at the message forwarded or replied-to."
;; removing the In-Reply-To header.
(save-restriction
(message-narrow-to-headers)
(let* ((fcc-path (message-fetch-field "Fcc")))
(when (eq mu4e-compose-type 'reply)
(unless (message-fetch-field "In-Reply-To")
(message-remove-header "References")))
(when use-hard-newlines
(mu4e--send-harden-newlines))
;; now handle what happens _after_ sending; typically, draft is gone and
;; the sent message appears in sent. Update flags for related messages,
;; i.e. for Forwarded ('Passed') and Replied messages, try to set the
;; appropriate flag at the message forwarded or replied-to.
(add-hook 'message-sent-hook
(lambda ()
(when fcc-path ;; hmmm... #2688
(when (eq mu4e-compose-type 'reply)
(unless (message-fetch-field "In-Reply-To")
(message-remove-header "References")))
(when use-hard-newlines
(mu4e--send-harden-newlines))
;; now handle what happens _after_ sending; typically, draft is gone and
;; the sent message appears in sent. Update flags for related messages,
;; i.e. for Forwarded ('Passed') and Replied messages, try to set the
;; appropriate flag at the message forwarded or replied-to.
(add-hook 'message-sent-hook
(lambda ()
(save-restriction
(message-narrow-to-headers)
(when-let ((fcc-path (message-fetch-field "Fcc")))
(mu4e--set-parent-flags fcc-path)
;; we end up with a ((buried) buffer here, visiting
;; the fcc-path; not quite sure why. But let's
;; get rid of it (#2681)
(when-let ((buf (find-buffer-visiting fcc-path)))
(kill-buffer buf))))
nil t))))
(kill-buffer buf)))))
nil t)))

;;; Crypto
(defun mu4e--compose-setup-crypto (parent compose-type)
Expand Down

0 comments on commit 9f47629

Please sign in to comment.