[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: posting-styles and bbdb "from"
From: |
David |
Subject: |
Re: posting-styles and bbdb "from" |
Date: |
Thu, 12 Feb 2009 14:19:28 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) |
Richard Riley <rileyrgdev@gmail.com> writes:
> I was wondering if anyone has a solution for setting the
> gnus-posting-style address based on a "email-from" field or similar on a
> contacts bbdb record?
Put the following function in your .gnus:
(defun DE-bbdb-match-field-recipient (field regexp)
"Match FIELD for recipient against REGEXP.
FIELD must be a symbol, e.g. 'gnus-private."
(let (who rec)
(when (and
(gnus-buffer-live-p gnus-article-copy)
(setq who
(with-current-buffer gnus-article-copy
(save-restriction
(nnheader-narrow-to-headers)
(or (message-fetch-field "reply-to")
(message-fetch-field "from")))))
(setq rec
(bbdb-search-simple
nil
(cadr (gnus-extract-address-components who)))))
(string-match regexp (bbdb-get-field rec field)))))
Then you can use this function in gnus-posting-styles as follows:
(setq gnus-posting-styles
'(
((DE-bbdb-match-field-recipient 'gnus-private "work")
(signature-file "~/work-sig.txt")
(address "address@work"))
((DE-bbdb-match-field-recipient 'gnus-private "other")
(signature-file "~/other-sig.txt")
(address "address@other"))
;; default rule
((DE-bbdb-match-field-recipient 'gnus-private "")
(address "address@default"))))
I use the 'gnus-private field, since I also do mail splitting via BBDB,
but you can use any field you want, of course.
-David