Gnus development mailing list
 help / color / mirror / Atom feed
* Posting styles override message-alternative-emails
@ 2005-09-10 11:36 Reiner Steib
  2005-09-10 20:37 ` Romain Francoise
  0 siblings, 1 reply; 6+ messages in thread
From: Reiner Steib @ 2005-09-10 11:36 UTC (permalink / raw)


Hi,

assume you have this values for `gnus-posting-styles'[1] and
`message-alternative-emails'[2]:

(setq
 gnus-posting-styles
 '((".*"
    (address "from-posting-styles@some-domain.invalid")
    (x-other "stuff")))
 message-alternative-emails "reiner.*steib"
 user-mail-address "user-mail@address.invalid")

When replying to a message with "To: Reiner Steib <reinersteib+gmane@imap.cc>"
the function `message-setup-1' inserts...

| From: reinersteib+gmane@imap.cc

But after this, `message-mode-hook' (?) modified by `gnus-msg.el'
unconditionally replaces the From with the value from
`gnus-posting-styles':

| From: Reiner Steib <from-posting-styles@some-domain.invalid>

Suggestions:

(1a) It should be documented that posting styles overwrite values from
     `message-alternative-emails'.

*or*

(1b) Posting styles should *not* overwrite the From if it was derived
     from `message-alternative-emails'.

I'd clearly prefer (1b).

(2) `message-alternative-emails' should also use `user-full-name'.

The feature to use "To" or "Cc" as "From" has often been requested (at
least in the German Gnus newsgroup).  Unaware of
`message-alternative-emails', I used this code[3] based on posting
styles upto now.

Bye, Reiner.

[1] (info "(gnus)Posting Styles")

[2]
,----[ (info "(message)Message Headers") ]
| `message-alternative-emails'
|      A regexp to match the alternative email addresses.  The first
|      matched address (not primary one) is used in the `From' field.
`----

[3]
--8<---------------cut here---------------start------------->8---
(defvar rs-message-to-from-addresses gnus-ignored-from-addresses
  "Regexp matching To headers.

When using entries like

  ((message-mail-p)
   (address (rs-message-to-from-address)))

or

  ((message-mail-p)
   (address (rs-message-to-from-address \"foo@example.invalid\")))

in `gnus-posting-styles', the address in the From header is taken
from the To header of the article you are replying to.")

;;;###autoload
(defun rs-message-to-from-address (&optional fallback)
  "Return a suitable address.

See `rs-message-to-from-addresses' for more."
  (let ((to (and (boundp 'gnus-article-buffer)
		 (gnus-buffer-live-p gnus-article-buffer)
		 ;; `gnus-buffer-live-p' already returns
		 ;; `gnus-article-buffer', but it's not documented.  So
		 ;; let's be careful.
		 gnus-article-buffer
		 (with-current-buffer gnus-article-buffer
		   (message-fetch-field "to")))))
    (cond ((and to
		(not (string-match "," to));; FIXME
		(string-match rs-message-to-from-addresses to))
	   (let ((from (cadr (mail-extract-address-components to))))
	     ;; gnus-extract-address-components fails for Outlook stuff:
	     ;; To: "'reiner.steib@...'" <reiner.steib@...>
	     (if (and (string-match rs-message-to-from-addresses from)
		      (string-match
		       (concat "^"
			       (if (boundp 'gnus-button-valid-localpart-regexp)
				   gnus-button-valid-localpart-regexp
				 "[a-z0-9-_+.]+")
			       "@" message-valid-fqdn-regexp "$")
		       from))
		 from
	       (if (y-or-n-p
		    (format "Address <%s> might be bogus.  Use anyway? "
			    from))
		   from))))
	  (fallback fallback)
	  (t user-mail-address))))
--8<---------------cut here---------------end--------------->8---
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

end of thread, other threads:[~2006-01-31 14:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-10 11:36 Posting styles override message-alternative-emails Reiner Steib
2005-09-10 20:37 ` Romain Francoise
2005-09-11  9:05   ` Reiner Steib
2005-09-11 16:53     ` Romain Francoise
2006-01-31 14:21       ` Reiner Steib
2006-01-31 14:46         ` Romain Francoise

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