mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 17:34:54 +01:00
emacs: Build forwarded message buffer more directly
Previously, we used `message-forward' to build forwarded messages, but this function is simply too high-level to be a good fit for some of what we do. First, since `message-forward' builds a full forward message buffer given the message to forward, we have to duplicate much of the logic in `notmuch-mua-mail' to patch the notmuch-y things into the built buffer. Second, `message-forward' constructs the From header from user-full-name and user-mail-address. As a result, if we prompt the user for an identity, we have to parse it into name and address components, just to have it put back together by `message-forward'. This process is not entirely loss-less because `mail-extract-address-components' does a lot of canonicalization (since it's intended for displaying addresses, not for parsing them). To fix these problems, don't use `message-forward' at all. `message-forward' itself is basically just a call to `message-mail' and `message-forward-make-body'. Do this ourselves, but call `notmuch-mua-mail' instead of `message-mail' so we can directly build a notmuch-y message and control the From header. This also fixes a bug that was a direct consequence of our use of `mail-extract-address-components': if the user chose an identity that had no name part (or the name part matched the mailbox), we would bind user-full-name to nil, which would cause an exception in the bowels of message-mode because user-full-name is expected to always be a string (even if it's just "").
This commit is contained in:
parent
01b82dc780
commit
1326ec09ee
1 changed files with 11 additions and 22 deletions
|
@ -231,21 +231,6 @@ list."
|
|||
(message-goto-body)
|
||||
(set-buffer-modified-p nil))
|
||||
|
||||
(defun notmuch-mua-forward-message ()
|
||||
(funcall (notmuch-mua-get-switch-function) (current-buffer))
|
||||
(message-forward)
|
||||
|
||||
(when notmuch-mua-user-agent-function
|
||||
(let ((user-agent (funcall notmuch-mua-user-agent-function)))
|
||||
(when (not (string= "" user-agent))
|
||||
(message-add-header (format "User-Agent: %s" user-agent)))))
|
||||
(message-sort-headers)
|
||||
(message-hide-headers)
|
||||
(set-buffer-modified-p nil)
|
||||
(notmuch-mua-maybe-set-window-dedicated)
|
||||
|
||||
(message-goto-to))
|
||||
|
||||
(defun notmuch-mua-mail (&optional to subject other-headers &rest other-args)
|
||||
"Invoke the notmuch mail composition window.
|
||||
|
||||
|
@ -345,13 +330,17 @@ The current buffer must contain an RFC2822 message to forward.
|
|||
|
||||
If PROMPT-FOR-SENDER is non-nil, the user will be prompted for
|
||||
the From: address first."
|
||||
(if (or prompt-for-sender notmuch-always-prompt-for-sender)
|
||||
(let* ((sender (notmuch-mua-prompt-for-sender))
|
||||
(address-components (mail-extract-address-components sender))
|
||||
(user-full-name (car address-components))
|
||||
(user-mail-address (cadr address-components)))
|
||||
(notmuch-mua-forward-message))
|
||||
(notmuch-mua-forward-message)))
|
||||
(let* ((cur (current-buffer))
|
||||
(message-forward-decoded-p nil)
|
||||
(subject (message-make-forward-subject))
|
||||
(other-headers
|
||||
(when (or prompt-for-sender notmuch-always-prompt-for-sender)
|
||||
(list (cons 'From (notmuch-mua-prompt-for-sender))))))
|
||||
(notmuch-mua-mail nil subject other-headers nil (notmuch-mua-get-switch-function))
|
||||
(message-forward-make-body cur)
|
||||
;; `message-forward-make-body' shows the User-agent header. Hide
|
||||
;; it again.
|
||||
(message-hide-headers)))
|
||||
|
||||
(defun notmuch-mua-new-reply (query-string &optional prompt-for-sender reply-all)
|
||||
"Compose a reply to the message identified by QUERY-STRING.
|
||||
|
|
Loading…
Reference in a new issue