Gnus development mailing list
 help / color / mirror / Atom feed
* Posting Styles: message-fetch-reply-field always returns nil
@ 1999-04-18 20:16 Peter von der Ahé
  1999-04-19  6:29 ` Lars Magne Ingebrigtsen
  1999-04-22 15:22 ` David S. Goldberg
  0 siblings, 2 replies; 5+ messages in thread
From: Peter von der Ahé @ 1999-04-18 20:16 UTC (permalink / raw)


Hi!

I have set up a posting style, which needs to look at the headers of
the mail being replied to:

(defun reply-to-ahedk-p ()
  "Return nil if not replying to a mail sent to ahe.dk"
  (save-excursion
    (and gnus-article-buffer
	 (set-buffer (get-buffer-create gnus-article-buffer))
	 (let ((to (gnus-fetch-field "to")))
	   (and to
		(string-match "@hatespam.ahe.dk" to))))))

(setq gnus-posting-styles
      '((reply-to-ahedk-p
	 (address "peter@hatespam.ahe.dk"))))

I think the reply-to-ahedk-p is kind of an ugly solution, it would
have been nicer to just write:

(defun reply-to-ahedk-p ()
  "Return nil if not replying to a mail sent to ahe.dk"
  (let ((to (message-fetch-reply-field "to")))
    (and to
	 (string-match "@hatespam.ahe.dk" to))))

Would it be possible to setup the posting styles when
message-fetch-reply-field can return something interesting?

Kind Regards
Peter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Posting Styles: message-fetch-reply-field always returns nil
  1999-04-18 20:16 Posting Styles: message-fetch-reply-field always returns nil Peter von der Ahé
@ 1999-04-19  6:29 ` Lars Magne Ingebrigtsen
  1999-04-19 12:58   ` Kai.Grossjohann
  1999-04-22 15:22 ` David S. Goldberg
  1 sibling, 1 reply; 5+ messages in thread
From: Lars Magne Ingebrigtsen @ 1999-04-19  6:29 UTC (permalink / raw)


nospam2159@daimi.au.dk (Peter von der Ahé) writes:

> Would it be possible to setup the posting styles when
> message-fetch-reply-field can return something interesting?

No, because the posting style stuff has to be run in the Message
buffer so that it can set buffer-local variables to influence Message
to generate the headers (and stuff) that it wants to.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Posting Styles: message-fetch-reply-field always returns nil
  1999-04-19  6:29 ` Lars Magne Ingebrigtsen
@ 1999-04-19 12:58   ` Kai.Grossjohann
  1999-04-21 19:01     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Kai.Grossjohann @ 1999-04-19 12:58 UTC (permalink / raw)


Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

  > nospam2159@daimi.au.dk (Peter von der Ahé) writes:
  > 
  > > Would it be possible to setup the posting styles when
  > > message-fetch-reply-field can return something interesting?
  > 
  > No, because the posting style stuff has to be run in the Message
  > buffer so that it can set buffer-local variables to influence Message
  > to generate the headers (and stuff) that it wants to.

Wasn't there a function which fetched headers from the original
message (the one being replied to)?  Or is there just this idiom?

(save-excursion
  (set-buffer gnus-article-buffer)
  (gnus-fetch-field "foo"))

kai
-- 
Abort this operation?   [Abort]  [Cancel]


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Posting Styles: message-fetch-reply-field always returns nil
  1999-04-19 12:58   ` Kai.Grossjohann
@ 1999-04-21 19:01     ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Magne Ingebrigtsen @ 1999-04-21 19:01 UTC (permalink / raw)


Kai.Grossjohann@CS.Uni-Dortmund.DE writes:

>   > > Would it be possible to setup the posting styles when
>   > > message-fetch-reply-field can return something interesting?

[...]

> Wasn't there a function which fetched headers from the original
> message (the one being replied to)?  Or is there just this idiom?
> 
> (save-excursion
>   (set-buffer gnus-article-buffer)
>   (gnus-fetch-field "foo"))

Yes, that's `message-fetch-reply-field'.  :-)  But it doesn't work
when doing posting styles since the buffer haven't been initialized
yet.  I think.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Posting Styles: message-fetch-reply-field always returns nil
  1999-04-18 20:16 Posting Styles: message-fetch-reply-field always returns nil Peter von der Ahé
  1999-04-19  6:29 ` Lars Magne Ingebrigtsen
@ 1999-04-22 15:22 ` David S. Goldberg
  1 sibling, 0 replies; 5+ messages in thread
From: David S. Goldberg @ 1999-04-22 15:22 UTC (permalink / raw)


I have the following in my gnus-posting-styles.  This lets me do the
right thing (for my definition of right thing) for replies.

(gnus-article-reply
 (signature-file
  (let* ((net
          (save-excursion
            (set-buffer gnus-article-buffer)
            (car
             (cdr
              (mail-extract-address-components
	       (message-fetch-field
		"From"))))))
	 (rec (car (bbdb-search
		    (bbdb-records) nil nil
		    net nil nil)))
	 (sig (if rec
		  (bbdb-record-getprop
		   rec 'signature))))
    (cond (sig sig)
	  ((string-match "@.*\\.?mitre\\.org" net)
	   "~/.signature-mitre-i")
	  ((string-match "nnml:personal.*"
			 gnus-newsgroup-name)
	   "~/.signature-personal")
	  (t "~/.signature-mitre"))))
 ("From"
  (let* ((net
	  (save-excursion
	    (set-buffer gnus-article-buffer)
	    (car
	     (cdr
	      (mail-extract-address-components
	       (message-fetch-field
		"From"))))))
	 (rec (car (bbdb-search
		    (bbdb-records) nil nil
		    net nil nil)))
	 (mail-from (if rec
			(bbdb-record-getprop
			 rec 'mail-from))))
    (cond (mail-from mail-from)
	  ((string-match "nnml:personal.*"
			 gnus-newsgroup-name)
	   "dsg@world.std.com (David S. Goldberg)")
	  (t (concat user-mail-address
		     " (David S. Goldberg)"))))))
-- 
Dave Goldberg
Post: The Mitre Corporation\MS B325\202 Burlington Rd.\Bedford, MA 01730
Phone: 781-271-3887
Email: dsg@mitre.org


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-04-22 15:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-18 20:16 Posting Styles: message-fetch-reply-field always returns nil Peter von der Ahé
1999-04-19  6:29 ` Lars Magne Ingebrigtsen
1999-04-19 12:58   ` Kai.Grossjohann
1999-04-21 19:01     ` Lars Magne Ingebrigtsen
1999-04-22 15:22 ` David S. Goldberg

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).