On Mon, 16 May 2011 19:29:07 +1000, Stewart Smith <stewart at flamingspork.com> 
wrote:
> Thought I'd share this bit of my .emacs snippet that may be useful to go
> on the emacs tips page.
> 
> This does the following:
> - sets up a list of possible identities to have mail From
> - on composing mail, it prompts you for who you want to send mail from
> - pressing enter will give you the default (first in the list)
> - otherwise you have tab completion

And here's the same for choosing the identity when forwarding a mail:

;; Choose the identity used to forward a mail
(defun schnouki/notmuch-mua-forward-message ()
  (interactive)
  (let* ((from (ido-completing-read "Sender identity: " schnouki/mua-identities
                                    nil nil nil nil (car 
schnouki/mua-identities)))
         (address-components (mail-extract-address-components from))
         (user-full-name (car address-components))
         (user-mail-address (cadr address-components)))
    (notmuch-mua-forward-message)))

(people who don't use or like ido may want to replace
ido-completing-read with completing-read)

If anyone is interested, I have some more useful snippets available on
https://github.com/Schnouki/dotfiles/blob/master/emacs/init-50-mail.el#L232:
- function to choose a signature according to the From header
- function to choose the sender identity according to the To header
  (useful for replying to work e-mails using your work address, or for
  replying to a ML with a subscribed address that won't be rejected)
- function to change the SMTP server that will be used for sending the
  mail according to the From header

It seriously lacks documentation so don't hesitate to ask if you have
any problem with it :)

Regards,

-- 
Thomas/Schnouki
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110516/221f9279/attachment-0001.pgp>

Reply via email to