Gnus development mailing list
 help / color / mirror / Atom feed
* How to split on content-length?
@ 2003-09-23  8:54 Tom Koelman
  2003-09-23 18:41 ` Hanak David
  2003-09-24  1:20 ` Jesper Harder
  0 siblings, 2 replies; 5+ messages in thread
From: Tom Koelman @ 2003-09-23  8:54 UTC (permalink / raw)



Hi,

I am using regular splitting to sort my mail in a lot of groups. Now I
would like to add a group containing all the "big" mails, with big
being defined as, say, bigger than 140k (Swen anyone?). I guess I
should write a function now to do that, because I don't think I can
use a regular expression to express that I want to split if
X-Content-Length: is followed by a number bigger dan 143360, but I
don't understand the doc. It says:

      The second element can also be a function.  In that case, it
      will be called narrowed to the headers with the first element of
      the rule as the argument.  It should return a non-`nil' value if
      it thinks that the mail belongs in that group.

Does this mean the second argument will contain the headers?

Tom




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

* Re: How to split on content-length?
  2003-09-23  8:54 How to split on content-length? Tom Koelman
@ 2003-09-23 18:41 ` Hanak David
  2003-09-24  1:20 ` Jesper Harder
  1 sibling, 0 replies; 5+ messages in thread
From: Hanak David @ 2003-09-23 18:41 UTC (permalink / raw)


On Tue, 23 Sep 2003, Tom Koelman wrote:

>       The second element can also be a function.  In that case, it
>       will be called narrowed to the headers with the first element of
>       the rule as the argument.  It should return a non-`nil' value if
>       it thinks that the mail belongs in that group.
>
> Does this mean the second argument will contain the headers?

No.  There is only one argument.  However, it will be called with the
currently active buffer containing the mail, narrowed to the header parts.
To narrow to the body part, call widen followed by gnus-narrow-to-body.

David



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

* Re: How to split on content-length?
  2003-09-23  8:54 How to split on content-length? Tom Koelman
  2003-09-23 18:41 ` Hanak David
@ 2003-09-24  1:20 ` Jesper Harder
  2003-09-24  6:44   ` Tom Koelman
  1 sibling, 1 reply; 5+ messages in thread
From: Jesper Harder @ 2003-09-24  1:20 UTC (permalink / raw)


Tom Koelman <tkoelman@xs4all.nl> writes:

> I am using regular splitting to sort my mail in a lot of groups. Now I
> would like to add a group containing all the "big" mails, with big
> being defined as, say, bigger than 140k (Swen anyone?). I guess I
> should write a function now to do that, because I don't think I can
> use a regular expression to express that I want to split if
> X-Content-Length: is followed by a number bigger dan 143360

You /could/ use a regexp, e.g.

    [1-9][4-9][0-9]\\{4,\\}

which matches any number greater than 139999.



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

* Re: How to split on content-length?
  2003-09-24  1:20 ` Jesper Harder
@ 2003-09-24  6:44   ` Tom Koelman
  2003-09-24 11:00     ` Ted Zlatanov
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Koelman @ 2003-09-24  6:44 UTC (permalink / raw)


Jesper Harder <harder@myrealbox.com> writes:

> Tom Koelman <tkoelman@xs4all.nl> writes:
>
>> use a regular expression to express that I want to split if
>> X-Content-Length: is followed by a number bigger dan 143360
>
> You /could/ use a regexp, e.g.
>
>     [1-9][4-9][0-9]\\{4,\\}
>
> which matches any number greater than 139999.

I don't think this will match anything for wich the last 5 digits are
a number between 00000 and 39999. But you gave me an idea and
I modified it to

\\(1[4-9]\\|[2-9][0-9]\\)[0-9]\\{4,\\}

which still has a problem with numbers containing more than 6 digits
of which the first is a 1 and the second smaller than 4. Adding
another bit like so

\\(1[4-9]\\|[2-9][0-9]\\|[1-9][0-9][0-9]\\)[0-9]\\{4,\\}

does the trick.

Thanks,
Tom




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

* Re: How to split on content-length?
  2003-09-24  6:44   ` Tom Koelman
@ 2003-09-24 11:00     ` Ted Zlatanov
  0 siblings, 0 replies; 5+ messages in thread
From: Ted Zlatanov @ 2003-09-24 11:00 UTC (permalink / raw)
  Cc: ding

On Wed, 24 Sep 2003, tkoelman@xs4all.nl wrote:

> I don't think this will match anything for wich the last 5 digits
> are a number between 00000 and 39999. But you gave me an idea and I
> modified it to
> 
> \\(1[4-9]\\|[2-9][0-9]\\)[0-9]\\{4,\\}
> 
> which still has a problem with numbers containing more than 6 digits
> of which the first is a 1 and the second smaller than 4. Adding
> another bit like so
> 
> \\(1[4-9]\\|[2-9][0-9]\\|[1-9][0-9][0-9]\\)[0-9]\\{4,\\}
> 
> does the trick.

That seems unnecessarily acrobatic.  Why not just match the digits and
compare them numerically to the number you want?  You can use
string-to-number, something like this might work (set data to the
header of interest and the action to what you want instead of the
message):

(let ((data "19874543435")
      (limit 150000))
  (when (and (string-match "\\([0-9]+\\)" data)
	     (> (string-to-number (match-string 1 data)) limit))
    (message "saw number greater than %d" limit)))

I would be very careful about using content-length for filtering.
Maybe you should consider doing that only if the message has an
executable attachment.

Ted



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

end of thread, other threads:[~2003-09-24 11:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-23  8:54 How to split on content-length? Tom Koelman
2003-09-23 18:41 ` Hanak David
2003-09-24  1:20 ` Jesper Harder
2003-09-24  6:44   ` Tom Koelman
2003-09-24 11:00     ` Ted Zlatanov

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