From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/72699 Path: news.gmane.org!not-for-mail From: Julien Danjou Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] gnus-expand-group-parameter: Only return and act on what was matched Date: Wed, 6 Oct 2010 18:33:13 +0200 Message-ID: <1286382793-19179-1-git-send-email-julien@danjou.info> NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1286382805 18013 80.91.229.12 (6 Oct 2010 16:33:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 6 Oct 2010 16:33:25 +0000 (UTC) Cc: Julien Danjou To: ding@gnus.org Original-X-From: ding-owner+M21071=ding+2Daccount=gmane.org@lists.math.uh.edu Wed Oct 06 18:33:23 2010 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P3Wvi-0000sU-Be for ding-account@gmane.org; Wed, 06 Oct 2010 18:33:22 +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 1P3Wve-0002Dx-T6 for ding-account@gmane.org; Wed, 06 Oct 2010 11:33:18 -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 1P3Wvd-0002Ds-TC for ding@lists.math.uh.edu; Wed, 06 Oct 2010 11:33:17 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1P3Wvc-00075V-0L for ding@lists.math.uh.edu; Wed, 06 Oct 2010 11:33:17 -0500 Original-Received: from coquelicot-s.easter-eggs.com ([213.215.37.94]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1P3Wvb-0003fw-00 for ; Wed, 06 Oct 2010 18:33:15 +0200 Original-Received: from cigue.easter-eggs.fr (cigue.easter-eggs.fr [10.0.0.33]) by rose.easter-eggs.fr (Postfix) with ESMTPS id 5F73314191; Wed, 6 Oct 2010 18:33:10 +0200 (CEST) Original-Received: from jdanjou by cigue.easter-eggs.fr with local (Exim 4.72) (envelope-from ) id 1P3Wva-0004zt-D8; Wed, 06 Oct 2010 18:33:14 +0200 X-Mailer: git-send-email 1.7.1 X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:72699 Archived-At: Signed-off-by: Julien Danjou --- Hi, Is something like the following acceptable? I've groups like: nnimap+Naquadah:lists.debian.devel and gnus-parameters set to something like: ("lists\\.debian\\.\\(.+\\)$" (gnus-use-scoring t) (to-list . "debian-\\1@lists.debian.org") (subscribed . t)))) With the current code, the To is set to nnimap+Naquadah:debian-devel@lists.debian.org which is annoying. :-( It only replaces what matched, but do not remove what was not matched. With that patch it does the right thing: debian-devel@lists.debian.org WDYT? lisp/ChangeLog | 3 +++ lisp/gnus.el | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7605a87..d5a0717 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2010-10-06 Julien Danjou + * gnus.el (gnus-expand-group-parameter): Only return and act on what + was matched. + * sieve-manage.el: Update example in `Commentary'. * sieve.el (sieve-open-server): Use sieve-manage-authenticate. diff --git a/lisp/gnus.el b/lisp/gnus.el index 531374b..64e2aa5 100644 --- a/lisp/gnus.el +++ b/lisp/gnus.el @@ -3809,12 +3809,13 @@ You should probably use `gnus-find-method-for-group' instead." (defun gnus-expand-group-parameter (match value group) "Use MATCH to expand VALUE in GROUP." - (with-temp-buffer - (insert group) - (goto-char (point-min)) - (while (re-search-forward match nil t) - (replace-match value)) - (buffer-string))) + (let ((start (string-match match group))) + (if start + (let ((matched-string (substring group start (match-end 0)))) + ;; Build match groups + (string-match match matched-string) + (replace-match value nil nil matched-string)) + group))) (defun gnus-expand-group-parameters (match parameters group) "Go through PARAMETERS and expand them according to the match data." -- 1.7.1