gnus-expand-group-parameter: Only return and act on what was matched
authorJulien Danjou <julien@danjou.info>
Wed, 6 Oct 2010 16:33:13 +0000 (18:33 +0200)
committerJulien Danjou <julien@danjou.info>
Fri, 8 Oct 2010 08:45:14 +0000 (10:45 +0200)
Signed-off-by: Julien Danjou <julien@danjou.info>
lisp/ChangeLog
lisp/gnus.el

index 32ee3a3..e556ee9 100644 (file)
@@ -81,6 +81,9 @@
 
 2010-10-06  Julien Danjou  <julien@danjou.info>
 
 
 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.
        * sieve-manage.el: Update example in `Commentary'.
 
        * sieve.el (sieve-open-server): Use sieve-manage-authenticate.
index b300fb6..4dbfb19 100644 (file)
@@ -3814,12 +3814,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."
 
 (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."
 
 (defun gnus-expand-group-parameters (match parameters group)
   "Go through PARAMETERS and expand them according to the match data."