Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Richard Riley <rileyrgdev@gmail.com>
To: info-gnus-english@gnu.org
Subject: Re: posting-styles and bbdb "from"
Date: Thu, 12 Feb 2009 16:43:27 +0100	[thread overview]
Message-ID: <gn1g32$v72$1@rileyrgdev.motzarella.org> (raw)
In-Reply-To: <mailman.549.1234444786.31690.info-gnus-english@gnu.org>

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

  parent reply	other threads:[~2009-02-12 15:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-11 20:45 Richard Riley
2009-02-12 13:19 ` David
     [not found] ` <mailman.549.1234444786.31690.info-gnus-english@gnu.org>
2009-02-12 15:43   ` Richard Riley [this message]
2009-02-12 17:13     ` Richard Riley
2009-02-12 22:56       ` David
2009-02-12 17:43     ` David
     [not found]     ` <mailman.572.1234460598.31690.info-gnus-english@gnu.org>
2009-02-13  4:28       ` Richard Riley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='gn1g32$v72$1@rileyrgdev.motzarella.org' \
    --to=rileyrgdev@gmail.com \
    --cc=info-gnus-english@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).