From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/84687 Path: news.gmane.org!not-for-mail From: Albert Krewinkel Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] gnus-msg.el (gnus-configure-posting-style): Allow string replacement when matching headers Date: Thu, 17 Jul 2014 11:26:14 +0200 Message-ID: <1405589174-20583-1-git-send-email-albert@zeitkraut.de> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1405636114 15100 80.91.229.3 (17 Jul 2014 22:28:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Jul 2014 22:28:34 +0000 (UTC) Cc: Albert Krewinkel To: ding@gnus.org Original-X-From: ding-owner+M32930@lists.math.uh.edu Fri Jul 18 00:28:28 2014 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X7uA7-00030X-9i for ding-account@gmane.org; Fri, 18 Jul 2014 00:28:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1X7u9N-00020A-GE; Thu, 17 Jul 2014 17:27:41 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1X7hy5-00074V-Tg for ding@lists.math.uh.edu; Thu, 17 Jul 2014 04:27:13 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1X7hy4-0004Rd-9Y for ding@lists.math.uh.edu; Thu, 17 Jul 2014 04:27:13 -0500 Original-Received: from reynholm.zeitkraut.de ([89.238.65.123]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1X7hy2-00022L-Dv for ding@gnus.org; Thu, 17 Jul 2014 11:27:10 +0200 Original-Received: by reynholm.zeitkraut.de (Postfix, from userid 106) id 60E182CA610C; Thu, 17 Jul 2014 09:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zeitkraut.de; s=mail; t=1405589255; bh=flI+algTt/3DkZkpv8S73SielVbHwxbDkVvJ/ZVReLY=; h=From:To:Cc:Subject:Date:From; b=oEsNCtpW561acFqt/cOnnq+tMevQ6p0n7IhotkINzSf/XeuvoWG5UsdgnDZ/Mszz7 g/UlIs/e1KZHXPU1wKdJx4Ir5M0blm/bVLgRLX/Te0/+/x6w4kEF5i82778Fdgx66n GuDdhxkk8yY09TSh9kskyJtYySnvq134OFe5fU+w= X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on reynholm.zeitkraut.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU autolearn=unavailable version=3.3.2 Original-Received: from espresso.fritz.box (dslb-188-108-215-252.pools.arcor-ip.net [188.108.215.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by reynholm.zeitkraut.de (Postfix) with ESMTPSA id 94EA82CA6103; Thu, 17 Jul 2014 09:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zeitkraut.de; s=mail; t=1405589252; bh=flI+algTt/3DkZkpv8S73SielVbHwxbDkVvJ/ZVReLY=; h=From:To:Cc:Subject:Date:From; b=XTaBbiRBpgzITJd078C5/QoE65iDgKJD0sye1BVqZnyPIJOmE8BqOPSUQnpmzJK5S 8hkDoe7Jrq4b2ls1cUlYnX0jdzBwN8XRtJVAIATSEr0NrkFf90Q9RRJHeCCl3k0usb zRJAU3AQiPIxWQ3MhrpPh15owANORo6fsMmcLzK8= X-Mailer: git-send-email 2.0.1 X-Spam-Score: -2.0 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:84687 Archived-At: 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 + + * gnus-msg.el (gnus-configure-posting-style): + Alllow string replacements in values when matching against a header. + 2014-07-07 Katsumi Yamaoka * 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