summaryrefslogtreecommitdiff
path: root/mu4e
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2024-12-07 19:40:33 +0200
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2024-12-07 19:40:33 +0200
commit5257ebcdf5223e7a79672fb8f9825ddd0241e92d (patch)
tree1e9606211341851def3536657c8e468a76eddb9c /mu4e
parent0e0d4a0cb60f6ce66dd6a07084adb6a1ec72d1d0 (diff)
mu4e-draft: add some logging to mu4e--set-parent-flags
Also a little refactoring. This should hopefully help with diagnosing #2478.
Diffstat (limited to 'mu4e')
-rw-r--r--mu4e/mu4e-draft.el44
1 files changed, 26 insertions, 18 deletions
diff --git a/mu4e/mu4e-draft.el b/mu4e/mu4e-draft.el
index c44ccae..884d5d5 100644
--- a/mu4e/mu4e-draft.el
+++ b/mu4e/mu4e-draft.el
@@ -387,26 +387,34 @@ also marked as Seen.
Function assumes that it is executed in the context of the
message buffer."
+ ;; note that we can't use mu4e-compose-parent-message here, since it
+ ;; no longer available when editing a draft. So we scan the outgoing
+ ;; message for the information.
(when-let* ((buf (find-file-noselect path)))
(with-current-buffer buf
- (let ((in-reply-to (message-field-value "in-reply-to"))
- (forwarded-from)
- (references (message-field-value "references")))
- (unless in-reply-to
- (when references
- (with-temp-buffer ;; inspired by `message-shorten-references'.
- (insert references)
- (goto-char (point-min))
- (let ((refs))
- (while (re-search-forward "<[^ <]+@[^ <]+>" nil t)
- (push (match-string 0) refs))
- ;; the last will be the first
- (setq forwarded-from (car refs))))))
- ;; remove the <> and update the flags on the server-side.
- (when (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to))
- (mu4e--server-move (match-string 1 in-reply-to) nil "+R-N"))
- (when (and forwarded-from (string-match "<\\(.*\\)>" forwarded-from))
- (mu4e--server-move (match-string 1 forwarded-from) nil "+P-N"))))))
+ (let* ((in-reply-to (message-field-value "in-reply-to"))
+ (references (message-field-value "references"))
+ (forwarded-from
+ (unless (or in-reply-to (not references))
+ (with-temp-buffer ;; inspired by `message-shorten-references'.
+ (insert references)
+ (goto-char (point-min))
+ (let ((refs))
+ (while (re-search-forward "<[^ <]+@[^ <]+>" nil t)
+ (push (match-string 0) refs))
+ (car refs))))) ;; the last shall be the first
+ ;; remove the <>
+ (in-reply-to (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to)
+ (match-string 1 in-reply-to)))
+ (forwarded-from (and forwarded-from (string-match "<\\(.*\\)>" forwarded-from)
+ (match-string 1 forwarded-from))))
+ ;; mark parents.
+ (when in-reply-to
+ (mu4e-log 'misc "mark %s as Replied" in-reply-to)
+ (mu4e--server-move in-reply-to nil "+R-N"))
+ (when forwarded-from
+ (mu4e-log 'misc "mark %s as Passed (forwarded)" forwarded-from)
+ (mu4e--server-move forwarded-from nil "+P-N"))))))
(defun mu4e--compose-after-save()
"Function called immediately after the draft buffer is saved."