From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/84691 Path: news.gmane.org!not-for-mail From: albert+gnus@zeitkraut.de Newsgroups: gmane.emacs.gnus.general Subject: [PATCH 1/2] gnus-msg.el (gnus-configure-posting-style): Allow string replacement when matching headers Date: Fri, 18 Jul 2014 09:29:42 +0200 Message-ID: <1405668583-14462-1-git-send-email-albert+gnus@zeitkraut.de> References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1405668676 32215 80.91.229.3 (18 Jul 2014 07:31:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Jul 2014 07:31:16 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M32933@lists.math.uh.edu Fri Jul 18 09:31:10 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 1X82dK-0001Hi-3O for ding-account@gmane.org; Fri, 18 Jul 2014 09:31:10 +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 1X82ch-0004Gv-JG; Fri, 18 Jul 2014 02:30:31 -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 1X82ce-0004Ga-2O for ding@lists.math.uh.edu; Fri, 18 Jul 2014 02:30:28 -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 1X82cc-0005aS-SQ for ding@lists.math.uh.edu; Fri, 18 Jul 2014 02:30:27 -0500 Original-Received: from reynholm.zeitkraut.de ([89.238.65.123]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1X82ca-0000OP-VK for ding@gnus.org; Fri, 18 Jul 2014 09:30:25 +0200 Original-Received: by reynholm.zeitkraut.de (Postfix, from userid 106) id 01AEC2CA610E; Fri, 18 Jul 2014 07:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zeitkraut.de; s=mail; t=1405668651; bh=y9TOyC4bBbDpS+F0ABizu0DvsYHa42QA07C75KyUssE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZaULM+uT2BYjrOJd622q0M6/FKO1YHz5P5Dw1ss3w9AVD5orC0nPr3pH6QyMme5F1 4ZKyf/ppL2XNIDAD/ebDuyLBofIwztD+tSJMwFM0h8mwuk7Mp+PKwZnRns0HXhj5Tv r/qmuajgolIZSt2QI9P9ikRLXGREqD0PtU8PHRpg= 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 207302CA6103 for ; Fri, 18 Jul 2014 07:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zeitkraut.de; s=mail; t=1405668650; bh=y9TOyC4bBbDpS+F0ABizu0DvsYHa42QA07C75KyUssE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QhQNeA0NCieO2CI80aqKGebwVZ8g5ZtJ80u6oo2iftDzLrFJzA0rg63QdklZhdApo 4RzrOCuWrxsfLORLAduU9HqQrdrXb3KoLsSnQDyR0GGXw+0hPfeCthoBt5dumdu9o0 qBk7Ksne3qy1vyBbWyyP0Htgib1RLDmmZwXxgeuI= X-Mailer: git-send-email 2.0.1 In-Reply-To: X-Spam-Score: -2.0 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:84691 Archived-At: From: Albert Krewinkel This allows for more flexible `gnus-posting-styles': ;; When using subaddresses (like me+gnus@example.com), reply from ;; 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..408318d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-07-17 Albert Krewinkel + + * gnus-msg.el (gnus-configure-posting-style): + Allow 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