Gnus development mailing list
 help / color / mirror / Atom feed
From: Julien Danjou <julien@danjou.info>
To: ding@gnus.org
Cc: Julien Danjou <julien@danjou.info>
Subject: [PATCH] gnus-expand-group-parameter: Only return and act on what was matched
Date: Wed,  6 Oct 2010 18:33:13 +0200	[thread overview]
Message-ID: <1286382793-19179-1-git-send-email-julien@danjou.info> (raw)

Signed-off-by: Julien Danjou <julien@danjou.info>
---
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  <julien@danjou.info>
 
+	* 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




             reply	other threads:[~2010-10-06 16:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-06 16:33 Julien Danjou [this message]
2010-10-07 20:10 ` Lars Magne Ingebrigtsen

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=1286382793-19179-1-git-send-email-julien@danjou.info \
    --to=julien@danjou.info \
    --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).