* nnmail-split-fancy usability problem
@ 2003-06-29 11:27 Florian Weimer
2003-06-29 13:33 ` Michael Cook
2003-06-30 23:24 ` Johan Bockgård
0 siblings, 2 replies; 4+ messages in thread
From: Florian Weimer @ 2003-06-29 11:27 UTC (permalink / raw)
Let's say we have list postings with the following header:
List-Id: An example list <list.example.com>
Say we want to use a generic rule which processes all lists at
example.com. The following doesn't work because "<" is not a word
constituent:
("List-Id" "<\\([a-z0-9-]+\\)\\.example\\.com>" "lists.example.\\1")
This doesn't work either because ".*" is greedy.
("List-Id" ".*\\([a-z0-9-]+\\)\\.example\\.com" "lists.example.\\1")
After rewriting, this results in an illegal regular expression (".*"
at the beginning is dropped unconditionally).
("List-Id" ".*?\\([a-z0-9-]+\\)\\.example\\.com" "lists.example.\\1")
Fortunately, the rule below works because the initial ".*" suppresses
the word constituent check:
("List-Id" ".*<\\([a-z0-9-]+\\)\\.example\\.com>.*" "lists.example.\\1")
However, we are a bit lucky. If there weren't the "<" character as a
marker, I think we would have a hard time working around the greedy
".*" in the header field matcher.
The following patch changes the implicit ".*" to ".*?". Okay to
apply?
(However, IMHO, the whole behavior of nnmail-split-fancy is highly
non-intuitive.)
2003-06-29 Florian Weimer <fw@deneb.enyo.de>
* nnmail.el (nnmail-split-it): Make header field match
non-greedy.
--- nnmail.el.~6.77.~ 2003-06-29 12:50:50.000000000 +0200
+++ nnmail.el 2003-06-29 13:19:13.000000000 +0200
@@ -1306,7 +1306,7 @@
(push split nnmail-split-trace))
(let ((split-rest (cddr split))
(end (match-end 0))
- ;; The searched regexp is \(\(FIELD\).*\)\(VALUE\).
+ ;; The searched regexp is \(\(FIELD\).*?\)\(VALUE\).
;; So, start-of-value is the point just before the
;; beginning of the value, whereas after-header-name
;; is the point just after the field name.
@@ -1366,7 +1366,7 @@
(if (symbolp field)
(cdr (assq field nnmail-split-abbrev-alist))
field)
- "\\):.*\\)"
+ "\\):.*?\\)"
(or partial-front "\\<")
"\\("
value
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nnmail-split-fancy usability problem
2003-06-29 11:27 nnmail-split-fancy usability problem Florian Weimer
@ 2003-06-29 13:33 ` Michael Cook
2003-06-29 13:37 ` Florian Weimer
2003-06-30 23:24 ` Johan Bockgård
1 sibling, 1 reply; 4+ messages in thread
From: Michael Cook @ 2003-06-29 13:33 UTC (permalink / raw)
Florian Weimer <fw@deneb.enyo.de> writes:
> The following patch changes the implicit ".*" to ".*?". Okay to
> apply?
i think that's an xemacs feature that emacs doesn't have yet.
m.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nnmail-split-fancy usability problem
2003-06-29 13:33 ` Michael Cook
@ 2003-06-29 13:37 ` Florian Weimer
0 siblings, 0 replies; 4+ messages in thread
From: Florian Weimer @ 2003-06-29 13:37 UTC (permalink / raw)
Cc: ding
Michael Cook <michael@waxrat.com> writes:
>> The following patch changes the implicit ".*" to ".*?". Okay to
>> apply?
>
> i think that's an xemacs feature that emacs doesn't have yet.
It's also available in GNU Emacs 21.
| ** Regular expressions now support intervals \{n,m\} as well as
| Perl's shy-groups \(?:...\) and non-greedy *? +? and ?? operators.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nnmail-split-fancy usability problem
2003-06-29 11:27 nnmail-split-fancy usability problem Florian Weimer
2003-06-29 13:33 ` Michael Cook
@ 2003-06-30 23:24 ` Johan Bockgård
1 sibling, 0 replies; 4+ messages in thread
From: Johan Bockgård @ 2003-06-30 23:24 UTC (permalink / raw)
Florian Weimer <fw@deneb.enyo.de> writes:
> The following patch changes the implicit ".*" to ".*?". Okay to
> apply?
--8<---------------cut here---------------start------------->8---
From: Lars Magne Ingebrigtsen <larsi@gnus.org>
Newsgroups: gnu.emacs.gnus
Subject: Re: [patch] Greedy pattern in nnmail-split-it
Date: Sat, 07 Jun 2003 19:51:41 +0200
Message-ID: <m3brx9n5ci.fsf@quimbies.gnus.org>
Dmitry Astapov <adept@umc.com.ua> writes:
> Here greedy match is used to glue together regexp for FIELD and
> regexp for VALUE, and this greedy match eats too much. Basically, it
> prevents user from using non-greedy matches at the beginning of
> VALUE in the nnmail-split-fancy at all.
>
> I propose to change ":.*" to ":.*?"
Well, this can't be changed in the stable Gnus series, so could you
suggest this again once the next development series starts?
--8<---------------cut here---------------end--------------->8---
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-06-30 23:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-29 11:27 nnmail-split-fancy usability problem Florian Weimer
2003-06-29 13:33 ` Michael Cook
2003-06-29 13:37 ` Florian Weimer
2003-06-30 23:24 ` Johan Bockgård
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).