info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: posting-styles and bbdb "from"


From: Richard Riley
Subject: Re: posting-styles and bbdb "from"
Date: Thu, 12 Feb 2009 16:43:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (gnu/linux)

David <de_bb@arcor.de> writes:

> 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:

Hi David,

I got it going. Great. I did have to define my own symbol though e.g

(setq email-type (make-symbol "email-type"))

Now, the question I have, having checked the posting styles manual, is
how best to optimise something like this?


(setq gnus-posting-styles
      `(
        (,(rx(or "DevelopmentEmail" "emacs" ))
         (name "Richard Riley")
         (address "rileyrgdev@googlemail.com")
         (from "Richard Riley <rileyrgdev@gmail.com>")
         )
        ((DE-bbdb-match-field-recipient 'email-type "dev")
         (name "Richard Riley")
         (address "rileyrgdev@googlemail.com")
         (from "Richard Riley <rileyrgdev@gmail.com>")
         )))

I understand that the first clause ",(rx.." produces a match string
(regexp) which is later evaluated against the group name. The second
searches for the email-type field and matches it is type "dev".

But how could I combine them so as not to have to repeat the other
forms?

regards

r.

        


>
> (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
>
>
>

-- 
 important and urgent problems of the technology of today are no longer the 
satisfactions of the primary needs or of archetypal wishes, but the reparation 
of the evils and damages by the technology of yesterday.  ~Dennis Gabor, 
Innovations:  Scientific, Technological and Social, 1970


reply via email to

[Prev in Thread] Current Thread [Next in Thread]