From e9fde9a29ea5fd81ab428e382ba498ed5bc8dce2 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 6 Oct 2010 18:33:13 +0200 Subject: [PATCH] gnus-expand-group-parameter: Only return and act on what was matched Signed-off-by: Julien Danjou --- lisp/ChangeLog | 3 +++ lisp/gnus.el | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 32ee3a3c5..e556ee97a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -81,6 +81,9 @@ 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 b300fb636..4dbfb1973 100644 --- a/lisp/gnus.el +++ b/lisp/gnus.el @@ -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." - (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." -- 2.34.1