From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/84685 Path: news.gmane.org!not-for-mail From: albert+gnus@zeitkraut.de 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 15:26:29 +0200 Message-ID: <1405603589-21887-1-git-send-email-albert+gnus@zeitkraut.de> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1405603731 18081 80.91.229.3 (17 Jul 2014 13:28:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Jul 2014 13:28:51 +0000 (UTC) Cc: Albert Krewinkel To: ding@gnus.org Original-X-From: ding-owner+M32928@lists.math.uh.edu Thu Jul 17 15:28:42 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 1X7ljm-000507-7Y for ding-account@gmane.org; Thu, 17 Jul 2014 15:28:42 +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 1X7liZ-00089z-Sf; Thu, 17 Jul 2014 08:27:27 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1X7liY-00089r-E9 for ding@lists.math.uh.edu; Thu, 17 Jul 2014 08:27:26 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1X7liW-0001MB-UM for ding@lists.math.uh.edu; Thu, 17 Jul 2014 08:27:26 -0500 Original-Received: from reynholm.zeitkraut.de ([89.238.65.123]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1X7liV-0000yV-HH for ding@gnus.org; Thu, 17 Jul 2014 15:27:23 +0200 Original-Received: by reynholm.zeitkraut.de (Postfix, from userid 106) id B8B1A2CA610C; Thu, 17 Jul 2014 13:27:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zeitkraut.de; s=mail; t=1405603669; bh=OklG9S7pJmnvjsrj4BR1vnuBhfh+If+L3ZlXlBMiCQA=; h=From:To:Cc:Subject:Date:From; b=OFjCH3WeSPde4pIAhHTwTdcB4SWSxwNioLY/kfj8UyU2zhmManArjX8CzLKGpLZLG ld+Cx5MfxmFqsg643txnRh2n5C/yZYjLxsrLeK1lWu7jkK4D9xF9/1Hsil0Lpdqkk7 lwVKnFwU4yn5St0KD+17v4IDmYtMIFvkXAKKKCA4= 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=ham 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 017972CA6108; Thu, 17 Jul 2014 13:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zeitkraut.de; s=mail; t=1405603669; bh=OklG9S7pJmnvjsrj4BR1vnuBhfh+If+L3ZlXlBMiCQA=; h=From:To:Cc:Subject:Date:From; b=OFjCH3WeSPde4pIAhHTwTdcB4SWSxwNioLY/kfj8UyU2zhmManArjX8CzLKGpLZLG ld+Cx5MfxmFqsg643txnRh2n5C/yZYjLxsrLeK1lWu7jkK4D9xF9/1Hsil0Lpdqkk7 lwVKnFwU4yn5St0KD+17v4IDmYtMIFvkXAKKKCA4= 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:84685 Archived-At: From: Albert Krewinkel 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