Gnus development mailing list
 help / color / mirror / Atom feed
* How to match '[' in nnmail-split-fancy
@ 2001-04-01 21:33 Nevin Kapur
  2001-04-01 21:53 ` Kai Großjohann
  0 siblings, 1 reply; 6+ messages in thread
From: Nevin Kapur @ 2001-04-01 21:33 UTC (permalink / raw)


Hi,

I'm having trouble matching the character '[' in nnmail-split-fancy. I
have the following split rule:

	("subject" "\\[.+\\] *$" "junk")

This does not match the following line in the *Summary* buffer:

R       01-Apr  [h1pzm@msn.com       ] Something EVERY business needs! [s83jy]

However in the *scratch* buffer:

(string-match "\\[.+\\] *$" "Something EVERY business needs! [s83jy]")
32

does what I want. What am I missing?

-- 
Nevin


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to match '[' in nnmail-split-fancy
  2001-04-01 21:33 How to match '[' in nnmail-split-fancy Nevin Kapur
@ 2001-04-01 21:53 ` Kai Großjohann
  2001-04-02  0:32   ` Nevin Kapur
  0 siblings, 1 reply; 6+ messages in thread
From: Kai Großjohann @ 2001-04-01 21:53 UTC (permalink / raw)
  Cc: ding

On 01 Apr 2001, Nevin Kapur wrote:

> I'm having trouble matching the character '[' in
> nnmail-split-fancy. I have the following split rule:
> 
> 	("subject" "\\[.+\\] *$" "junk")

Fancy splitting matches on word boundaries, but `[' can never be the
start of a word, so you lose.  Try ".*\\[.+\\] *$", note the initial
`.*'. 

kai
-- 
Be indiscrete.  Do it continuously.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to match '[' in nnmail-split-fancy
  2001-04-01 21:53 ` Kai Großjohann
@ 2001-04-02  0:32   ` Nevin Kapur
  2001-04-02  6:05     ` Kai Großjohann
  0 siblings, 1 reply; 6+ messages in thread
From: Nevin Kapur @ 2001-04-02  0:32 UTC (permalink / raw)


On Sun, 01 Apr 2001, Kai Großjohann wrote:

> On 01 Apr 2001, Nevin Kapur wrote:
> 
>> I'm having trouble matching the character '[' in
>> nnmail-split-fancy. I have the following split rule:
>> 
>> 	("subject" "\\[.+\\] *$" "junk")
> 
> Fancy splitting matches on word boundaries, but `[' can never be the
> start of a word, so you lose.  Try ".*\\[.+\\] *$", note the initial
> `.*'. 

It looks to me like fancy splitting matches on word boundaries at the
*end* of words, i.e., the above regexp produces

^\\(\\(subject\\):.*\\)\\(\\[.+\\] *$\\)\\>

in nnmail-fancy-split. I can't think of any way to match ']' (or for
that matter any other character that is not a legal word boundary) at the
end of the string with this restriction.

Perhaps someone with better regexp skills than me can help...

-- 
Nevin


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to match '[' in nnmail-split-fancy
  2001-04-02  0:32   ` Nevin Kapur
@ 2001-04-02  6:05     ` Kai Großjohann
  2001-04-02 15:46       ` Nevin Kapur
  0 siblings, 1 reply; 6+ messages in thread
From: Kai Großjohann @ 2001-04-02  6:05 UTC (permalink / raw)
  Cc: ding

On 01 Apr 2001, Nevin Kapur wrote:

> It looks to me like fancy splitting matches on word boundaries at
> the *end* of words,

Isn't there some special-casing when the regexp starts with ".*"?  I
think when Gnus sees this, it omits the leading \\< that it would
normally insert.

> i.e., the above regexp produces
> 
> ^\\(\\(subject\\):.*\\)\\(\\[.+\\] *$\\)\\>
> 
> in nnmail-fancy-split. I can't think of any way to match ']' (or for
> that matter any other character that is not a legal word boundary)
> at the end of the string with this restriction.
> 
> Perhaps someone with better regexp skills than me can help...

I think a similar trick should be done for the end of the regexp.
Hm...  Yes, look after line 1232 in nnmail.el, there you can see the
special case for splits beginning with ".*".  I think partial should
be renamed to partial-front and a similar partial-rear variable should
be introduced.

Opinions?

kai
-- 
Be indiscrete.  Do it continuously.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to match '[' in nnmail-split-fancy
  2001-04-02  6:05     ` Kai Großjohann
@ 2001-04-02 15:46       ` Nevin Kapur
  2001-04-11 11:52         ` Kai Großjohann
  0 siblings, 1 reply; 6+ messages in thread
From: Nevin Kapur @ 2001-04-02 15:46 UTC (permalink / raw)


On Mon, 02 Apr 2001, Kai Großjohann wrote:

> I think a similar trick should be done for the end of the regexp.
> Hm... Yes, look after line 1232 in nnmail.el, there you can see the
> special case for splits beginning with ".*". I think partial should
> be renamed to partial-front and a similar partial-rear variable
> should be introduced.
> 
> Opinions?

It makes sense to me. If there is a consensus to add this twist,
here's the patch against the latest CVS.

cvs server: Diffing lisp
Index: lisp/ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/ChangeLog,v
retrieving revision 6.393
diff -u -r6.393 ChangeLog
--- lisp/ChangeLog	2001/04/01 23:25:12	6.393
+++ lisp/ChangeLog	2001/04/01 15:35:16
@@ -1,3 +1,8 @@
+2001-04-02  Nevin Kapur  <nevin@jhu.edu>
+
+	* nnmail.el (nnmail-split-it): Added check for .* at the end of
+	regexp in nnmail-split-fancy.
+
 2001-04-02 00:40:12  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 	* message.el (message-check-news-header-syntax): Question even
Index: lisp/nnmail.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/nnmail.el,v
retrieving revision 6.10
diff -u -r6.10 nnmail.el
--- lisp/nnmail.el	2001/02/08 23:53:22	6.10
+++ lisp/nnmail.el	2001/04/01 15:35:20
@@ -1233,22 +1233,29 @@
      (t
       (let* ((field (nth 0 split))
 	     (value (nth 1 split))
-	     partial regexp)
+	     partial-front regexp
+	     partial-rear  regexp)
 	(if (symbolp value)
 	    (setq value (cdr (assq value nnmail-split-abbrev-alist))))
 	(if (and (>= (length value) 2)
 		 (string= ".*" (substring value 0 2)))
 	    (setq value (substring value 2)
-		  partial ""))
+		  partial-front ""))
+	;; Same trick for the rear of the regexp
+	(if (and (>= (length value) 2)
+		 (string= ".*" (substring value -2)))
+	    (setq value (substring value 0 -2)
+		  partial-rear ""))
 	(setq regexp (concat "^\\(\\("
 			     (if (symbolp field)
 				 (cdr (assq field nnmail-split-abbrev-alist))
 			       field)
 			     "\\):.*\\)"
-			     (or partial "\\<")
+			     (or partial-front "\\<")
 			     "\\("
 			     value
-			     "\\)\\>"))
+			     "\\)"
+			     (or partial-rear "\\>")))
 	(push (cons split regexp) nnmail-split-cache)
 	;; Now that it's in the cache, just call nnmail-split-it again
 	;; on the same split, which will find it immediately in the cache.


-- 
Nevin


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to match '[' in nnmail-split-fancy
  2001-04-02 15:46       ` Nevin Kapur
@ 2001-04-11 11:52         ` Kai Großjohann
  0 siblings, 0 replies; 6+ messages in thread
From: Kai Großjohann @ 2001-04-11 11:52 UTC (permalink / raw)
  Cc: ding

On 02 Apr 2001, Nevin Kapur wrote:

> It makes sense to me. If there is a consensus to add this twist,
> here's the patch against the latest CVS.

Committed.

kai
-- 
Be indiscrete.  Do it continuously.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-04-11 11:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-01 21:33 How to match '[' in nnmail-split-fancy Nevin Kapur
2001-04-01 21:53 ` Kai Großjohann
2001-04-02  0:32   ` Nevin Kapur
2001-04-02  6:05     ` Kai Großjohann
2001-04-02 15:46       ` Nevin Kapur
2001-04-11 11:52         ` Kai Großjohann

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).