From: albert+gnus@zeitkraut.de
To: ding@gnus.org
Cc: Albert Krewinkel <albert@zeitkraut.de>
Subject: [PATCH] gnus-msg.el (gnus-configure-posting-style): Allow string replacement when matching headers
Date: Thu, 17 Jul 2014 15:26:29 +0200 [thread overview]
Message-ID: <1405603589-21887-1-git-send-email-albert+gnus@zeitkraut.de> (raw)
From: Albert Krewinkel <albert@zeitkraut.de>
This allows for more flexible `gnus-posting-styles':
;; When using subaddresses like `me+gnus@example.com', reply with
;; using the address the message was send to.
(setq gnus-posting-style
'(((header "x-original-to" "me\\(\\+.+\\)?@example.com")
(address "me\\1@example.com"))))
---
lisp/ChangeLog | 5 +++++
lisp/gnus-msg.el | 13 ++++++++-----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0861557..dd6ade5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2013-07-17 Albert Krewinkel <albert@zeitkraut.de>
+
+ * gnus-msg.el (gnus-configure-posting-style):
+ Alllow string replacements in values when matching against a header.
+
2014-07-07 Katsumi Yamaoka <yamaoka@jpl.org>
* gnus-start.el (gnus-dribble-read-file): Don't stop the auto-saving of
diff --git a/lisp/gnus-msg.el b/lisp/gnus-msg.el
index 1c8635c..93e9877 100644
--- a/lisp/gnus-msg.el
+++ b/lisp/gnus-msg.el
@@ -1826,7 +1826,7 @@ this is a reply."
(with-current-buffer gnus-summary-buffer
gnus-posting-styles)
gnus-posting-styles))
- style match attribute value v results
+ style match attribute value v results matched-string
filep name address element)
;; If the group has a posting-style parameter, add it at the end with a
;; regexp matching everything, to be sure it takes precedence over all
@@ -1846,7 +1846,9 @@ this is a reply."
(when (cond
((stringp match)
;; Regexp string match on the group name.
- (string-match match group))
+ (when (string-match match group)
+ (setq matched-string group)
+ t))
((eq match 'header)
;; Obsolete format of header match.
(and (gnus-buffer-live-p gnus-article-copy)
@@ -1875,7 +1877,8 @@ this is a reply."
(nnheader-narrow-to-headers)
(let ((header (message-fetch-field (nth 1 match))))
(and header
- (string-match (nth 2 match) header)))))))
+ (string-match (nth 2 match) header)
+ (setq matched-string header)))))))
(t
;; This is a form to be evalled.
(eval match)))))
@@ -1896,10 +1899,10 @@ this is a reply."
(setq v
(cond
((stringp value)
- (if (and (stringp match)
+ (if (and matched-string
(gnus-string-match-p "\\\\[&[:digit:]]" value)
(match-beginning 1))
- (gnus-match-substitute-replacement value nil nil group)
+ (gnus-match-substitute-replacement value nil nil matched-string)
value))
((or (symbolp value)
(functionp value))
--
2.0.1
next reply other threads:[~2014-07-17 13:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-17 13:26 albert+gnus [this message]
2014-07-17 15:58 ` Andreas Schwab
2014-07-17 23:47 ` Katsumi Yamaoka
2014-07-18 5:03 ` Albert Krewinkel
2014-07-18 7:29 ` [PATCH 1/2] " albert+gnus
2014-07-18 7:29 ` [PATCH 2/2] gnus.texi (Posting Styles): Document string replacement when matching against headers albert+gnus
2014-07-18 8:20 ` Katsumi Yamaoka
-- strict thread matches above, loose matches on Subject: below --
2014-07-17 9:26 [PATCH] gnus-msg.el (gnus-configure-posting-style): Allow string replacement when matching headers Albert Krewinkel
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=1405603589-21887-1-git-send-email-albert+gnus@zeitkraut.de \
--to=albert+gnus@zeitkraut.de \
--cc=albert@zeitkraut.de \
--cc=ding@gnus.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).