[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lisp recipe to set From header
From: |
David Z Maze |
Subject: |
Re: Lisp recipe to set From header |
Date: |
Fri, 27 Jan 2006 17:39:45 -0500 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (usg-unix-v) |
Matthew King <matthew.king@monnsta.net> writes:
> I have the following:
>
> ;;; Set From header based on To header
> (setq gnus-posting-styles
> '(("nn.+:"
> (From (save-excursion
> (set-buffer gnus-article-buffer)
> (message-fetch-field "to"))))))
>
> What I really want to do is only set the From address to be one from a
> pre-set list and to fall back on user-mail-address if there is no
> match.
;; Totally untested:
(defvar mk-to-header-list
'("matthew.king@monnsta.net")
"Names it's valid to take from the To: header of messages.")
(defun mk-to-header-or-default ()
"Returns the To: header of `gnus-article-buffer' if it's in
`mk-to-header-list', or `user-mail-address' otherwise."
(let ((to-header (save-excursion
(set-buffer gnus-article-buffer)
(message-fetch-field "to"))))
(if (member to-header mk-to-header-list)
to-header
gnus-article-buffer)))
(setq gnus-posting-styles '(("nn.+:" (From (mk-to-header-or-default)))))
--dzm