* Lisp recipe to set From header
@ 2006-01-27 21:34 Matthew King
2006-01-27 22:12 ` Sébastien Kirche
2006-01-27 22:39 ` David Z Maze
0 siblings, 2 replies; 3+ messages in thread
From: Matthew King @ 2006-01-27 21:34 UTC (permalink / raw)
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"))))))
Which, as the comment says, sets the From header to be that of the
previous mail's To header. I have problems with my address being in the
Cc header instead or with there being more than one address in To, but
this is not important.
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.
I don't know anywhere near enough lisp to write this though, so how
would I go about doing this?
Matthew
--
I must take issue with the term "a mere child," for it has been my
invariable experience that the company of a mere child is infinitely
preferable to that of a mere adult.
-- Fran Lebowitz
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Lisp recipe to set From header
2006-01-27 21:34 Lisp recipe to set From header Matthew King
@ 2006-01-27 22:12 ` Sébastien Kirche
2006-01-27 22:39 ` David Z Maze
1 sibling, 0 replies; 3+ messages in thread
From: Sébastien Kirche @ 2006-01-27 22:12 UTC (permalink / raw)
At 22:34 on Jan 27 2006, Matthew King said :
> I don't know anywhere near enough lisp to write this though, so how
> would I go about doing this?
If I understand correctly, you should take a look to
message-alternative-emails that provides exactly that : when replying to
a message where the To: is in the alternatives, that address is
automagicaly used for the From: of the reply. Otherwise it uses the
styles or the user-mail-address.
Its value should be a regexp, so regexp-opt could be useful to build it.
Here is an example :
(setq message-alternative-emails
(regexp-opt (cons user-mail-address
'("first@domain.net"
"second.value@other.fr"
"another@value.net"
))))
HTH.
--
Sébastien Kirche
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Lisp recipe to set From header
2006-01-27 21:34 Lisp recipe to set From header Matthew King
2006-01-27 22:12 ` Sébastien Kirche
@ 2006-01-27 22:39 ` David Z Maze
1 sibling, 0 replies; 3+ messages in thread
From: David Z Maze @ 2006-01-27 22:39 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-01-27 22:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-27 21:34 Lisp recipe to set From header Matthew King
2006-01-27 22:12 ` Sébastien Kirche
2006-01-27 22:39 ` David Z Maze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).