* [PATCH] gnus-expand-group-parameter: Only return and act on what was matched
@ 2010-10-06 16:33 Julien Danjou
2010-10-07 20:10 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: Julien Danjou @ 2010-10-06 16:33 UTC (permalink / raw)
To: ding; +Cc: Julien Danjou
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-10-07 20:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-06 16:33 [PATCH] gnus-expand-group-parameter: Only return and act on what was matched Julien Danjou
2010-10-07 20:10 ` Lars Magne Ingebrigtsen
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).