🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #56518

Re: slrn 's' command, slight misfeature?

#56518
From: Thomas Schultz
Date: Fri, 07 Jan 2000 00:00
143 lines
5820 bytes
On 05 January 2000 at 13:18 GMT, Chris Green <cgreen@shell.x-1.net> wrote:

> When using the 's' command in slrn to search article subjects it
> strikes me that once I've found a thread with the search string in
> the subject I don't want to find all the subsequent articles in the
> same thread when I hit 's' again.

Although this is not precisely what you are asking for, you might
consider using "temporary scoring" instead of searching. Some people
in de.comm.software.newsreader find it more convenient and if you
don't, the macro may be a starting point for your own.

You can "temporarily score" on author, subject and body of a message.
Each article that matches your search will receive a score you can
define by setting Temp_Score_Value (default is 1000); you can decide
if you want the "temporary scores" to override your usual scoring or
if you want them to be added to existing scores (this is the default,
set Temp_Score_Additive to 0 to change it).

The slang file below will automatically bind the macro to the key '�'
when interpreted by slrn. There is also additional functionality for
users of the NN emulation (the macro will notice when nn.sl is loaded
and automatically enable it) - matching articles will automatically be
'tagged' so you can navigate through them using the ']' and '[' keys.
Some former NN users told me they liked this macro better than the
original functionality of the NN newsreader.

To all slang experts: I would be happy to learn how this code could be
improved. In particular, I do not like the way the re-sorting of the
articles is done - finding out the sorting_method, ungetkey()ing it
and calling "toggle_sort" does work, but seems somewhat awkward.

Here we go...

% -*- slang -*-

% This macro allows one to "temporarily score" the current newsgroup based
% on subject, author or body. It binds the function 'temp_score_newsgroup'
% to the '%' key in article mode.

% The following variables can be used to influence the macro's behaviour:
% Temp_Score_Value    - score that will be given to any article matching
%                       the search
% Temp_Score_Additive - if nonzero, the macro will add "score" to existing
%                       scores; if zero, it will simply overwrite them

variable Temp_Score_Value = 1000;
variable Temp_Score_Additive = 1;

% The macro is able to tag matching headers so you can select them using
% the functions defined in nn.sl. This is done only if you load nn.sl
% before this file.

variable Temp_Score_Nn_Tag_Header = is_defined("nn_tag_header");
variable Temp_Score_Last_Search_Str = "";


define temp_score_newsgroup ()
{
   variable str;
   variable deleted;
   variable mode;
   variable metamail; % Turn off use_metamail while searching
   metamail = get_variable_value("use_metamail");
   set_integer_variable("use_metamail",0);
   
   mode = get_response ("aAbBsS", "Temporarily score based on "+
				    "\001Author, \001Body or \001Subject?");
   
   str = read_mini ("Score on regexp", Search_Last_Art_Search_Str, "");
   if (str == "")
     return;

   Search_Last_Art_Search_Str = str;
   
   uncollapse_threads ();
   while(header_up(1));

   if ((mode == 'b') or (mode == 'B'))
     {
	do % cycle through all articles, scanning their bodies
	  {
	     deleted = (get_header_flags() & HEADER_READ);
	     
	     if (re_search_article (str))
	       {
		  pop ();
		  if (Temp_Score_Additive)
		    set_header_score(get_header_score + Temp_Score_Value);
		  else set_header_score(Temp_Score_Value);
		  if (Temp_Score_Nn_Tag_Header)
		    eval("nn_tag_header ();");
	       }
	     else !if (Temp_Score_Additive) set_header_score(0);
	     
	     !if (deleted)
	       set_header_flags (get_header_flags() & ~(HEADER_READ));
	     
	     call ("hide_article");
	  } while (header_down(1));
     }
   else
     {
	!if (Temp_Score_Additive) % set all scores to 0 first
	  {
	     do set_header_score(0); while (header_down(1));
	     while (header_up(1));
	  }
	
	switch(mode) % search for matching articles
	  {
	   case 'a' or case 'A' :
	     while (re_fsearch_author(str))
	       {
		  set_header_score(get_header_score + Temp_Score_Value);
		  if (Temp_Score_Nn_Tag_Header)
		    eval("nn_tag_header();");
		  !if (header_down(1)) break;
	       }	     
	  }
	  {
	   case 's' or case 'S' :
	     while (re_fsearch_subject(str))
	       {
		  set_header_score(get_header_score + Temp_Score_Value);
		  if (Temp_Score_Nn_Tag_Header)
		    eval("nn_tag_header();");
		  !if (header_down(1)) break;
	       }	     
	  }
     }
   
   collapse_threads();
   ungetkey(typecast((string(get_variable_value("sorting_method"))),
		     Integer_Type));
   call("toggle_sort");
   while (header_up(1));
   
   set_integer_variable("use_metamail", metamail); % restore metamail setting
}
definekey ("temp_score_newsgroup", "�", "article");

Technical Details
Message-ID: <slrn87aebn.1un.tststs@starflower.tststs.ddns.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
References: <slrn876gun.tul.cgreen@shell.x-1.net>

Show Full Headers
Complete Article Headers
Message-ID: <slrn87aebn.1un.tststs@starflower.tststs.ddns.org>
Subject: Re: slrn 's' command, slight misfeature?
Date: Fri, 07 Jan 2000 00:00:00 +0000
From: tststs@gmx.de (Thomas Schultz)
References: <slrn876gun.tul.cgreen@shell.x-1.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
X-Deja-AN: 569339863
Content-Transfer-Encoding: 8bit
X-Server-Date: 7 Jan 2000 00:52:21 GMT
Content-Type: text/plain; charset=iso-8859-1
X-Complaints-To: abuse@cityweb.de
Organization: Cityweb News Service
User-Agent: slrn/0.9.6.2+ (Linux)
Mime-Version: 1.0
NNTP-Posting-Date: 7 Jan 2000 00:54:37 GMT
Newsgroups: news.software.readers