mirror of https://github.com/djcb/mu.git
mu4e-compose: use narrow-to-header before fetch
This commit is contained in:
parent
9557ba43a0
commit
be63bf2f80
|
@ -448,7 +448,7 @@ If MSGPATH is nil, do nothing."
|
||||||
;; older Emacsen (<= 28 perhaps?) won't update the Date
|
;; older Emacsen (<= 28 perhaps?) won't update the Date
|
||||||
;; if there already is one; so make sure it's gone.
|
;; if there already is one; so make sure it's gone.
|
||||||
(message-remove-header "Date")
|
(message-remove-header "Date")
|
||||||
(message-generate-headers '(Date)))
|
(message-generate-headers '(Date Subject From)))
|
||||||
(mu4e--delimit-headers 'undelimit))) ;; remove separator
|
(mu4e--delimit-headers 'undelimit))) ;; remove separator
|
||||||
|
|
||||||
(defvar mu4e--compose-buffer-max-name-length 48)
|
(defvar mu4e--compose-buffer-max-name-length 48)
|
||||||
|
@ -487,25 +487,26 @@ message buffer."
|
||||||
(let ((buf (find-file-noselect path)))
|
(let ((buf (find-file-noselect path)))
|
||||||
(when buf
|
(when buf
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(message-narrow-to-headers-or-head)
|
(save-restriction
|
||||||
(let ((in-reply-to (message-fetch-field "in-reply-to"))
|
(message-narrow-to-headers)
|
||||||
(forwarded-from)
|
(let ((in-reply-to (message-fetch-field "in-reply-to"))
|
||||||
(references (message-fetch-field "references")))
|
(forwarded-from)
|
||||||
(unless in-reply-to
|
(references (message-fetch-field "references")))
|
||||||
(when references
|
(unless in-reply-to
|
||||||
(with-temp-buffer ;; inspired by `message-shorten-references'.
|
(when references
|
||||||
(insert references)
|
(with-temp-buffer ;; inspired by `message-shorten-references'.
|
||||||
(goto-char (point-min))
|
(insert references)
|
||||||
(let ((refs))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward "<[^ <]+@[^ <]+>" nil t)
|
(let ((refs))
|
||||||
(push (match-string 0) refs))
|
(while (re-search-forward "<[^ <]+@[^ <]+>" nil t)
|
||||||
;; the last will be the first
|
(push (match-string 0) refs))
|
||||||
(setq forwarded-from (car refs))))))
|
;; the last will be the first
|
||||||
;; remove the <> and update the flags on the server-side.
|
(setq forwarded-from (car refs))))))
|
||||||
(when (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to))
|
;; remove the <> and update the flags on the server-side.
|
||||||
(mu4e--server-move (match-string 1 in-reply-to) nil "+R-N"))
|
(when (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to))
|
||||||
(when (and forwarded-from (string-match "<\\(.*\\)>" forwarded-from))
|
(mu4e--server-move (match-string 1 in-reply-to) nil "+R-N"))
|
||||||
(mu4e--server-move (match-string 1 forwarded-from) nil "+P-N")))))))
|
(when (and forwarded-from (string-match "<\\(.*\\)>" forwarded-from))
|
||||||
|
(mu4e--server-move (match-string 1 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."
|
||||||
|
@ -706,9 +707,11 @@ With HEADERS-ONLY non-nil, only include the headers part."
|
||||||
;; in rare (broken) case, if a message-id is missing use the generated one
|
;; in rare (broken) case, if a message-id is missing use the generated one
|
||||||
;; from mu.
|
;; from mu.
|
||||||
(mu4e--delimit-headers)
|
(mu4e--delimit-headers)
|
||||||
(unless (message-fetch-field "Message-Id")
|
(save-restriction
|
||||||
(goto-char (point-min))
|
(message-narrow-to-headers)
|
||||||
(insert (format "Message-Id: <%s>\n" (plist-get msg :message-id))))
|
(unless (message-fetch-field "Message-Id")
|
||||||
|
(goto-char (point-min))
|
||||||
|
(insert (format "Message-Id: <%s>\n" (plist-get msg :message-id)))))
|
||||||
(mu4e--delimit-headers 'undelimit)
|
(mu4e--delimit-headers 'undelimit)
|
||||||
(ignore-errors (run-hooks 'gnus-article-decode-hook))
|
(ignore-errors (run-hooks 'gnus-article-decode-hook))
|
||||||
(buffer-substring-no-properties (point-min) (point-max))))
|
(buffer-substring-no-properties (point-min) (point-max))))
|
||||||
|
@ -809,12 +812,14 @@ This is mu4e's version of `message-hidden-headers'.")
|
||||||
FUNC is the original function, and ARGS are its arguments.
|
FUNC is the original function, and ARGS are its arguments.
|
||||||
Is this address yours?"
|
Is this address yours?"
|
||||||
(if (mu4e-running-p)
|
(if (mu4e-running-p)
|
||||||
(let ((sender (message-fetch-field "from"))
|
(save-restriction
|
||||||
(from (message-fetch-field "sender")))
|
(message-narrow-to-headers)
|
||||||
(or (and sender (mu4e-personal-or-alternative-address-p
|
(let ((sender (message-fetch-field "from"))
|
||||||
(car (mail-header-parse-address sender))))
|
(from (message-fetch-field "sender")))
|
||||||
(and from (mu4e-personal-or-alternative-address-p
|
(or (and sender (mu4e-personal-or-alternative-address-p
|
||||||
(car (mail-header-parse-address from))))))
|
(car (mail-header-parse-address sender))))
|
||||||
|
(and from (mu4e-personal-or-alternative-address-p
|
||||||
|
(car (mail-header-parse-address from)))))))
|
||||||
(apply func args)))
|
(apply func args)))
|
||||||
|
|
||||||
(defun mu4e--compose-setup-post (compose-type &optional parent)
|
(defun mu4e--compose-setup-post (compose-type &optional parent)
|
||||||
|
@ -972,15 +977,17 @@ must be from current user, as determined through
|
||||||
(mu4e--delimit-headers)
|
(mu4e--delimit-headers)
|
||||||
;; message-forward expects message-reply-headers to be set up; here we
|
;; message-forward expects message-reply-headers to be set up; here we
|
||||||
;; only need message-id & references, rest is for completeness.
|
;; only need message-id & references, rest is for completeness.
|
||||||
(setq-local message-reply-headers
|
(save-restriction
|
||||||
(make-full-mail-header
|
(message-narrow-to-headers)
|
||||||
0
|
(setq-local message-reply-headers
|
||||||
(or (message-fetch-field "subject") "none")
|
(make-full-mail-header
|
||||||
(or (message-fetch-field "from") "nobody")
|
0
|
||||||
(message-fetch-field "date")
|
(or (message-fetch-field "subject") "none")
|
||||||
(message-fetch-field "message-id" t)
|
(or (message-fetch-field "from") "nobody")
|
||||||
(message-fetch-field "references")
|
(message-fetch-field "date")
|
||||||
0 0 ""))
|
(message-fetch-field "message-id" t)
|
||||||
|
(message-fetch-field "references")
|
||||||
|
0 0 "")))
|
||||||
(mu4e--delimit-headers 'undelimit)
|
(mu4e--delimit-headers 'undelimit)
|
||||||
(set-buffer-modified-p nil)
|
(set-buffer-modified-p nil)
|
||||||
(message-forward)))))
|
(message-forward)))))
|
||||||
|
|
Loading…
Reference in New Issue