]> git.notmuchmail.org Git - notmuch/commit
emacs: Build forwarded message buffer more directly
authorAustin Clements <amdragon@MIT.EDU>
Thu, 20 Feb 2014 19:16:34 +0000 (14:16 -0500)
committerDavid Bremner <david@tethera.net>
Sat, 22 Feb 2014 23:50:55 +0000 (19:50 -0400)
commit1326ec09ee369b152a6c9bed5fe42c2d80180d01
treeb19675a26a702c903d9c847d659cf8fd8b0205b9
parent01b82dc780670a7e3d314c56b4699fcf9d70046a
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 "").
emacs/notmuch-mua.el