Article View: news.software.readers
Article #234847Re: [slrn] Can I make a rule that will auto-ignore all follow-ups to a certain author?
From: John E. Davis
Date: Thu, 30 Jul 2009 16:23
Date: Thu, 30 Jul 2009 16:23
128 lines
5187 bytes
5187 bytes
On Wed, 29 Jul 2009 05:40:14 +0000 (UTC), ShadowTek <ShadowTek@invalid.invalid>
wrote:
> But now I've gotten to a part that involes complex string functions that
> I'm unfamiliar with:
>
> variable expression = "(string_match("+hdr+
> ",\"[^ ]+ +[^ ]+ +<.+@.+>\",1) == 0) and (string_match("+hdr+
> ",\"peter\\.bergt\",1) == 0) and (string_match("+hdr+
> ",\".+@.+ +([^ ]+ [^ ]+.+)\", 1) == 0)";
>
> Can anyone explain what's going on here, step-by-step?
I have no idea why it was written in this form. Here is a revised
form of this function that I think is more clear:
#v+
define auto_kill_fups ()
{
if (is_group_mode ())
error (_function_name () + " doesn't work in group mode!");
uncollapse_threads;
call ("header_bob");
% variable trace_file = "/home/themel/slang-log" ;
variable trace_file = "/dev/null" ;
variable of = fopen(trace_file, "w") ;
do
{
variable from = extract_article_header ("From");
if ((0 == string_match (from, "[^ ]+ +[^ ]+ +<.+@.+>", 1))
&& (0 == string_match (from, "peter\\.bergt", 1))
&& (0 == string_match (from, ".+@.+ +([^ ]+ [^ ]+.+)", 1)))
{
variable mid = extract_article_header("Message-Id");
if (of != NULL)
() = fprintf (of, "MID %s is fake (%s), killing + FUp's", mid, from);
% mid = str_quote_string (mid, "\\^$[]*.+?", '\\');
set_header_flags(get_header_flags() | HEADER_READ);
ignore_subthread();
}
} while (header_down(1));
call ("header_bob");
collapse_threads;
}
#v-
Note the following code fragment:
#v+
if ((0 == string_match (from, "[^ ]+ +[^ ]+ +<.+@.+>", 1))
&& (0 == string_match (from, "peter\\.bergt", 1))
&& (0 == string_match (from, ".+@.+ +([^ ]+ [^ ]+.+)", 1)))
#v-
(NOTE: If you are using slang-2.0.x instead of slang-2.1.x or slang-2.2.x,
you will need to replace "&&" by "and" in the above)
This performs 3 tests on the from string, and if all fail the
"if-block" will get executed. The first test requires that the string
match the RE "[^ ]+ +[^ ]+ +<.+@.+>", which says that the "From"
header value contain a portion that looks like:
"X Y <W@Z>"
where X, Y, W, Z represent 1 or more non-space characters.
The second test matches "peter.bergt". Perhaps he wrote the macro.
The final one matches:
"S@T (X YU)"
where S, T, and U represent 1 or more characters.
In other words, the filter will mark subthreads as read if the From
header does not contain values formatted according to one of the above
patterns.
Finally, I think that the ignore_subthread function should be
rewritten to not open a pipe for each subthread. That is, instead of
#v+
define ignore_subthread ()
{
if (is_group_mode ())
error (_function_name () + " doesn't work in group mode!");
variable p_handle, datestring;
p_handle = popen("date --date '21 days' '+%m/%d/%Y'","r");
() = fgets(&datestring, p_handle);
() = pclose(p_handle);
set_input_string (strcat("-9998\n",datestring));
set_input_chars ("rty");
call ("create_score");
}
#v-
I would use:
#v+
private variable Twenty_One_Days_Ago = NULL;
define ignore_subthread ()
{
if (is_group_mode ())
error (_function_name () + " doesn't work in group mode!");
if (Twenty_One_Days_Ago == NULL)
{
variable p_handle;
p_handle = popen("date --date '21 days' '+%m/%d/%Y'","r");
() = fgets(&Twenty_One_Days_Ago, p_handle);
() = pclose(p_handle);
}
set_input_string (strcat("-9998\n",Twenty_One_Days_Ago));
set_input_chars ("rty");
call ("create_score");
}
#v-
Better yet, I would avoid the pipe altogether by making use of the
`strftime' function.
I hope this helps.
--John
Technical Details
Message-ID:
<slrnh73i74.imu.jed@aluche.mit.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!newsfeed20.multikabel.net!multikabel.net!newsfeed10.multikabel.net!xlned.com!feeder3.xlned.com!newsfeed.kpn.net!pfeed09.wxs.nl!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mailReferences:
<guhtt9$82j$1@news.motzarella.org> <slrnh0p4lk.9q2.catwheezel@ID-107770.user.individual.net> <slrnh6sm2b.be4.ShadowTek@desktop.localdomain> <20090729080451@usenet.piggo.com> <slrnh6v215.m8d.ShadowTek@desktop.localdomain> <20090729101510@usenet.piggo.com> <slrnh6vnoo.8ce.ShadowTek@desktop.localdomain>Show Full Headers
Complete Article Headers
Message-ID: <slrnh73i74.imu.jed@aluche.mit.edu> Subject: Re: [slrn] Can I make a rule that will auto-ignore all follow-ups to a certain author? Date: Thu, 30 Jul 2009 16:23:00 +0000 From: "John E. Davis" <jed@jedsoft.org> References: <guhtt9$82j$1@news.motzarella.org> <slrnh0p4lk.9q2.catwheezel@ID-107770.user.individual.net> <slrnh6sm2b.be4.ShadowTek@desktop.localdomain> <20090729080451@usenet.piggo.com> <slrnh6v215.m8d.ShadowTek@desktop.localdomain> <20090729101510@usenet.piggo.com> <slrnh6vnoo.8ce.ShadowTek@desktop.localdomain> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!newsfeed20.multikabel.net!multikabel.net!newsfeed10.multikabel.net!xlned.com!feeder3.xlned.com!newsfeed.kpn.net!pfeed09.wxs.nl!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mail Newsgroups: news.software.readers Reply-To: jed@jedsoft.org User-Agent: slrn/pre1.0.0-11 (Linux) Lines: 128 NNTP-Posting-Host: ALUCHE.MIT.EDU X-Trace: 1248970980 senator-bedfellow.mit.edu 505 18.75.2.45