mu4e-draft: add some logging to mu4e--set-parent-flags
Also a little refactoring. This should hopefully help with diagnosing #2478.
This commit is contained in:
@ -387,26 +387,34 @@ also marked as Seen.
|
|||||||
|
|
||||||
Function assumes that it is executed in the context of the
|
Function assumes that it is executed in the context of the
|
||||||
message buffer."
|
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)))
|
(when-let* ((buf (find-file-noselect path)))
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(let ((in-reply-to (message-field-value "in-reply-to"))
|
(let* ((in-reply-to (message-field-value "in-reply-to"))
|
||||||
(forwarded-from)
|
(references (message-field-value "references"))
|
||||||
(references (message-field-value "references")))
|
(forwarded-from
|
||||||
(unless in-reply-to
|
(unless (or in-reply-to (not references))
|
||||||
(when references
|
|
||||||
(with-temp-buffer ;; inspired by `message-shorten-references'.
|
(with-temp-buffer ;; inspired by `message-shorten-references'.
|
||||||
(insert references)
|
(insert references)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(let ((refs))
|
(let ((refs))
|
||||||
(while (re-search-forward "<[^ <]+@[^ <]+>" nil t)
|
(while (re-search-forward "<[^ <]+@[^ <]+>" nil t)
|
||||||
(push (match-string 0) refs))
|
(push (match-string 0) refs))
|
||||||
;; the last will be the first
|
(car refs))))) ;; the last shall be the first
|
||||||
(setq forwarded-from (car refs))))))
|
;; remove the <>
|
||||||
;; remove the <> and update the flags on the server-side.
|
(in-reply-to (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to)
|
||||||
(when (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to))
|
(match-string 1 in-reply-to)))
|
||||||
(mu4e--server-move (match-string 1 in-reply-to) nil "+R-N"))
|
(forwarded-from (and forwarded-from (string-match "<\\(.*\\)>" forwarded-from)
|
||||||
(when (and forwarded-from (string-match "<\\(.*\\)>" forwarded-from))
|
(match-string 1 forwarded-from))))
|
||||||
(mu4e--server-move (match-string 1 forwarded-from) nil "+P-N"))))))
|
;; 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()
|
(defun mu4e--compose-after-save()
|
||||||
"Function called immediately after the draft buffer is saved."
|
"Function called immediately after the draft buffer is saved."
|
||||||
|
|||||||
Reference in New Issue
Block a user