Thread View: news.software.readers
6 messages
6 total messages
Started by Christian Perrier
Sun, 10 Oct 1999 00:00
[slrn] Macro for killing an entire thread?
Author: Christian Perrier
Date: Sun, 10 Oct 1999 00:00
Date: Sun, 10 Oct 1999 00:00
16 lines
1311 bytes
1311 bytes
Before starting to mess up with slang code by myself, I would like to know is someone already has written such a beast : -a macro which would extract from the headers of the current article the FIRST References entry and then create a Score entry based on it for killing the entire thread. The idea behind : being able to kill an entire thread when positionned on *ANY* article belonging to this thread (not only the first one). This is a kind of extension to the possibilities of what is behind the "K" key --
Re: [slrn] Macro for killing an entire thread?
Author: Dawn Owens-Nicholson
Date: Wed, 13 Oct 1999 00:00
Date: Wed, 13 Oct 1999 00:00
66 lines
3284 bytes
3284 bytes
Christian Perrier wrote:
> [A] macro which would extract from the headers of the current article
> the FIRST References entry and then create a Score entry based on it
> for killing the entire thread.
This won't work as well as you would hope. Some newsreaders don't preserve
the entire References: header so some references (message-IDs) will be lost
in long threads. If an early reference (the first message-ID, for instance)
is lost, the article won't be scored as you intend. Scoring on a single
reference works best when you're trying to kill a subthread--a branch of a
discussion--because they don't often grow very long.
Putting that aside, this may be what you were looking for. This macro
appends a score entry to the scorefile without going through the kill
prompter (less programming for me, less upkeep for you). Unfortunately this
means you'll have to hardcode the path to your scorefile (for now--perhaps
in the future slrn's scorefile will become a 'set' variable).
I've modified the request to kill all articles with /any/ of the references
in their References: header so the chance of killing long threads increases.
If you use this macro on the first article in a thread (an article with no
References: header), you can test how well it works on killing an entire
thread according to your original wish.
implements ("my");
static variable scorefile = "path_to_my_scorefile_here"; % <= EDIT THIS LINE!
static define kill_thread ()
{
if (is_group_mode ())
error (_function_name () + " doesn\'t work in group mode.");
variable fp = fopen (scorefile, "a");
% variable fp = fopen (get_variable_value ("scorefile"), "a");
if (fp == NULL) error ("Couldn\'t open scorefile: " + errno_string (errno));
variable line;
foreach (["[*] % Killing " + extract_article_header ("Subject"),
" Score:: =" + string (get_variable_value ("kill_score"))])
{
line = () + "\n";
if (-1 == fputs (line, fp))
error ("Can\'t write to scorefile: " + errno_string (errno));
}
variable
msgID,
header = "References",
refs = extract_article_header (header);
!if (strlen (refs)) % Must be a thread-starter
{
header = "Message-ID";
refs = extract_article_header (header);
}
foreach (strtok (refs))
{
msgID = ();
if (-1 == fputs (sprintf (" %s: %s\n", header, msgID), fp))
error ("Can\'t write to scorefile: " + errno_string (errno));
}
if (-1 == fclose (fp))
error ("Can\'t close scorefile: " + errno_string (errno));
}
Re: [slrn] Macro for killing an entire thread?
Author: Dawn Owens-Nicholson
Date: Wed, 13 Oct 1999 00:00
Date: Wed, 13 Oct 1999 00:00
9 lines
1191 bytes
1191 bytes
I posted some code in <slrn80835v.l6k.bluemoon@ux6.cso.uiuc.edu> and I forgot to mention that this macro won't make slrn reload the scorefile, so all the changes won't take effect until you either restart slrn or edit the scorefile with the create_score intrinsic (bound to "k" by default). I know it's not as smooth as it could be, but for a little while, hit ESC 1 k then exit your scorefile editor when you're done killing all the threads you want to kill with this macro.
Re: [slrn] Macro for killing an entire thread?
Author: Christian Perrier
Date: Thu, 14 Oct 1999 00:00
Date: Thu, 14 Oct 1999 00:00
28 lines
1980 bytes
1980 bytes
Dawn Owens-Nicholson <bluemoon@ux6.cso.uiuc.edu> wrote : >This won't work as well as you would hope. Some newsreaders don't preserve >the entire References: header so some references (message-IDs) will be lost >in long threads. If an early reference (the first message-ID, for instance) I'm aware of this. For instance, Agent is such a culprit, which removes the first References header, making some of my scores fail (I actually kill threads by going over the first article of the thread and use K, then R). But your code will improve greatly my scoring system, thanks! I have now to find an idea for inserting an Expires: header so that I don't have a continuously growing Score file (when Score entries expire, I am warned by slrn and thus can edit my score file manually for removing them). Is there a way to call en external command and insert its result into s lang variable? I'm considering somehtin like : date=`date` (with proper arguments to the Unix date command, of course). The date variable would then be used to build the Expires entry.
Re: [slrn] Macro for killing an entire thread?
Author: John E. Davis
Date: Mon, 18 Oct 1999 00:00
Date: Mon, 18 Oct 1999 00:00
20 lines
1604 bytes
1604 bytes
On 16 Oct 1999 15:42:59 GMT, Dawn Owens-Nicholson <bluemoon@ux6.cso.uiuc.edu>
wrote:
> implements ("my");
> define system (cmd)
> {
> variable
> tempfile = "/tmp/tempfile",
> retval = system (sprintf ("%s >%s", cmd, tempfile)),
This function appears to recursively call `my->system' even though the
last function call results in a call to Global->system. For clarity,
I think that it is better to explicitly specify that the last function
call is to the `system' function in the global name table:
retval = Global->system (sprintf ("%s >%s", cmd, tempfile)),
--John
Re: [slrn] Macro for killing an entire thread?
Author: Christian Perrier
Date: Tue, 19 Oct 1999 00:00
Date: Tue, 19 Oct 1999 00:00
21 lines
1735 bytes
1735 bytes
John E. Davis <davis@space.mit.edu> wrote :
>This function appears to recursively call `my->system' even though the
>last function call results in a call to Global->system. For clarity,
By the way, I take this opportunity and thank everyone who
contributed in this thread.
Your pieces of code solved my problem.... I now just have to upgrade
my slang/slrn/jed installation : I use all the stuff on a Linux
Debian 2.1 ("stable") system, where slang is 1.2.2, jed is 0.98.7...
Using the code needs an upgrade to slang 1.3.9, thus jed has to be
upgraded to 0.99.9 and so on.... Not a so easy task..:-). The fun of
"binary-only" setups...
--
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads