🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #255434

[slrn] Solution to the age-old question

#255434
From: ernobe
Date: Tue, 27 Aug 2013 22:21
193 lines
6725 bytes
I gave up on a previous attempt to solve what is a pretty simple problem 
because it required a complex set of macros which placed too much burden on 
slrn and still didn't solve the problem completely.  

The problem is how to place a mark on only the latest never before seen 
messages within a thread.  

The other attempt had to reconstruct the whole thread on entry to the group, 
and all the other messages within it appeared marked as read.  So here is the 
real deal.  It only takes a pretty simple Icon program, running slrnpull in 
rebuild mode, scoring the articles by age, a simple macro within slrn to tag 
the newest articles, and setting sorting method to custom for better 
appearance of the results.  

The Icon program changes the date of each article to yesterday with the --date 
option of date in Unix ( date --date=yesterday ).  Before running slrnpull 
you have to run it with the --rebuild option so as to rebuild the overview 
files.  By scoring the articles that are younger than one day, like this

[*]
Score: 1
Age: 1

then all the newer articles received from the server are the only ones to 
receive a high score and are distinguished with a mark within slrn.  If the 
last time you downloaded was more than one day ago you will have to change the 
behaviour of the date command and the score accordingly.

The score file scores the articles by age so that the ones older than a day 
are also marked.  The youngest ones are tagged, those at least two days old 
are not marked at all, to avoid clutter and to make the newest ones more 
visible, and those three and five days old are also marked.

[*]
Score: -2
Age: 4

[*]
Score: -3
Age: 3

[*]
Score: -4
Age: 2

[*]
Score: -5
Age: 1

Then in .slrnrc put the following and remember to run slrnpull with the 
--kill-score option to -16 or else it will kill all the articles.

set max_low_score -16
set min_high_score -5 

Here is the macro within slrn to tag the articles.  

    define tag_high_score ()
    {
        call ("header_bob");
        do
        {  
            if ( (-14) == get_header_score ())  
            {
		set_header_flags (HEADER_TAGGED);
            }
            if ( (0) == get_header_score ())  
            {
		set_header_flags (12);
            }
        }
        while (header_down (1));
    }
    
    () = register_hook ("article_mode_hook", "tag_high_score" );

I need to look up slangs' case function for better coding.  Anyway, you need 
to put this in a file and call it from .slrnrc like this:

interpret yourfile.sl

Also put these two for navigating to the tagged articles.  They move to the 
tagged article and open it for viewing.  I've only been able to open it for 
viewing with the article_line_down function.

    define prevheader ()
    {
	if (1 == prev_tagged_header ())
	{
	    if (0 == get_body_status ())
	    	article_line_down (1);
	    if (0 == has_parent ())
		collapse_threads ();
	}
    }

    define nextheader ()
    {
	if (1 == next_tagged_header ())
	{
	    if (0 == get_body_status ())
		article_line_down (1);
	    if (0 == has_parent ())
		collapse_threads ();
	}
    }
    definekey ("nextheader", "7", "article" );
    definekey ("prevheader", "6", "article" );

And here is the sorting method in .slrnrc:

set sorting_method 12
set custom_sort_order "body,score,Date|date" 
set custom_sort_by_threads 1

This shows the newest threads and articles at the top by their scores and 
dates.  Within the threads though it shows the oldest articles first.

Finally for those who want to take a look at it, here is the Icon code.  In 
adition to changing the date to yesterday, it adds a new header ( X-URL: ) so 
that it is marked as not needing to be re-dated.  Thereafter only the 
immediately previous downloaded articles dates are changed.

Note that this works on Linux.  It requires tweaking for other operating 
systems.

procedure main( x )
d := []
s0 := read( open( "date --date=yesterday \"+%a, %d %b %Y %T %z\"", "p" ) )
s4 := open( "/home/roy/News/spool/slrnpull.conf" ) | stop( "no slrnpull conf file" )
while s1 := read( s4 ) do {
    if s1[ 1 ] == "#" then next
    s1 ? {
	s2 := tab( upto( ' ' ) | 0 )
	if s2 == ( "default" | "" ) then next
	    else put( d, s2 )
	} 
    }
every man( m1( !d ), s0 )
end

procedure m1( s5 )
f := "/home/roy/News/spool/news/"
s5 ? { while s1 := tab( upto( '.' ) ) do 
    { f ||:= s1 || "/" 
	move( 1 ) 
	}
    f ||:= tab( 0 ) || "/"
    }
return f
end

procedure man( s, s0 )
no := "no"
n := open( "ls " || s, "p" ) | stop( "unable to list ", s )
while p := read( n ) do {
    numeric( p ) | next
    a := open( s2 := s || p, "rw" ) | stop( "unable to open a:", s2 )
    g := read( a )
    if g == "X-URL: " then 
	{ close( a )
	next
	} 
	else { t := open( s3 := s2 || "new", "crw" ) | stop( "unable to open t:", s3 )
	write( t, "X-URL: \n", g )
	}
    while b := read( a ) do {
	if b[1:6] == "Date:" then 
	    { write( t, "Date: ", s0 )
	    no := "yes" 
	    } 
	    else write( t, b ) 
	}
    if no == "yes" then no := "no"
	else { seek( t, 1 )
	    seek( a, 1 )
	write( t, "X-URL: \nDate: ", s0 )
	while write( t, read( a ) ) 
	}
    system( "mv " || s3 || " " || s2 )
    close( a )
    close( t )
    }
close( n )
write( "finished ", s )
return
end

		    
-- 
"The world of existence is an emanation of the merciful attribute of God."
Abdu'l-Baha
http://www.costarricense.cr/pagina/ernobe
Technical Details
Message-ID: <kvj8oe$f5$1@dont-email.me>
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.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <kvj8oe$f5$1@dont-email.me>
Subject: [slrn] Solution to the age-old question
Date: Tue, 27 Aug 2013 22:21:02 +0000
From: ernobe <ernobe@yahoo.com>
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.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
Newsgroups: news.software.readers
Organization: World Order of Baha'u'llah
Lines: 193
Injection-Date: Tue, 27 Aug 2013 22:21:02 +0000 (UTC)
Injection-Info: mx05.eternal-september.org;
 posting-host="aa62c9dfd94aa8dd21cd89a27766d80d";
 logging-data="485"; mail-complaints-to="abuse@eternal-september.org";
 posting-account="U2FsdGVkX1+WkNAnzxWKwKacI3G5l+ap"
User-Agent: slrn/pre1.0.0-18 (Linux)
Cancel-Lock: sha1:S/s6RvxF+0mo641qA19bFYb3U5Y=
X-Original-Bytes: 6500