🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #41214

Re: slrn needs trn-like thread handling

#41214
From: Dawn Owens-Nicholson
Date: Fri, 29 May 1998 00:00
221 lines
9543 bytes
Rob Funk wrote:
> With a little S-Lang work, the prefix argument could probably be
> worked around... but is there any way to fix the thread user
> interface?

You are correct about using S-Lang macros to bind the prefix
functionality to other keys, however, "fix[ing]" something requires
that thing to be broken first and slrn's thread display (even though
you don't like it) is functional and correct according to its
documentation.  Unfortunately for you, in the current version of slrn,
no S-Lang macro can modify the display in the way you want.  Perhaps
in a future version this will become possible.

You could make slrn jump to articles within a thread (read or not) by
using a macro to move the selection arrow within the thread (for the
unread articles) or parse the References: headers of various articles
in the thread and then jump around to those articles.  I'm not
familiar with trn's thread movement capabilities, so I can't be more
specific on what to do, but it sounds like you'd want to use
extract_article_header(), call("locate_header_by_msgid") and linked
lists.  The first is documented in the doc/README.macros file, the
second is a slrn intrinsic and implementing the third in S-Lang is
documented in S-Lang's doc/text/slang.txt file, in case you are
unfamiliar with slrn and S-Lang.

There are a couple of bugs in extract_article_header() and the
locate_header_by_msgid intrinsic you should know about since they will
impact your macro.  I've included workaround macros below to help you.

  * extract_article_header() in slrn 0.9.5.2 will prepend a space to
    the message-ID of an article depending on its read status.  It's
    easy to work around, use:

       strtrim (extract_article_header ("Message-ID"))

    instead.  The strtrim() will remove leading and trailing
    whitespace.  This problem might exist for other headers too,
    but I rarely need to extract other headers, so I haven't noticed
    everything yet.

  * locate_header_by_msgid will unnecessarily uncollapse collapsed
    thread displays.  If the article you're searching for is the
    first article of a collapsed thread, the thread will be
    uncollapsed before the arrow (or bar) is left on the article.
    This is easy to work around also, but it means not being able
    to use the intrinsic as freely as you might want.

  * locate_header_by_msgid will add an article to a header list if
    the article is not present in the list but it's on the server.
    This can be annoying if you only want to know if a header is
    present.  The enhanced_locate_article_by_msgid() workaround
    below should help with this.

These bugs have been reported, but they're far from show-stoppers.  If
you use the workaround macros, your macro might not work as fast as
you'd like on large header listings, but as they say, they work well
for me.



% Bugfix for slrn's extract_article_header()        % -*- slang -*-

% Fixes extract_article_header() for known problem areas

define bugfix_extract_article_header (header)
{
   if (header == "Message-ID")
     return (strtrim (extract_article_header (header)));
   else
     return (extract_article_header (header));
}

define bugfix_locate_header_by_msgid ()
{
   % With collapsed threads, the intrinsic locate_header_by_msgid will
   % unnecessarily uncollapse a thread.  This function fixes that and
   % only uses the non-buggy portions of locate_header_by_msgid.

   variable sought_message_ID = read_mini ("Enter Message-Id", "", "");
   !if (strlen (sought_message_ID)) return ();

   variable starting_header = extract_article_header ("Message-ID");

   call ("header_bob");                          % go to top of article list

   % The do-while loop moves the pointer from thread to thread while the
   % inner for loop checks the articles in each thread.  The collapse
   % status of the display is only disturbed when the desired message-ID
   % is found inside a thread.
   do
     {
	variable
	  thread_was_collapsed = is_thread_collapsed (),
	  t_size = thread_size (),
	  position;

	for (position = 1; position <= t_size; position++)
	  {
	     if (sought_message_ID == extract_article_header ("Message-ID"))
	       return ();

	     if (position == 1) uncollapse_thread ();
	     else if (andelse
		       { position == t_size }    % at end of thread
		       { thread_was_collapsed })
	       collapse_thread ();

	     if (position != t_size) () = header_down (1);
	  }
     }
   while (header_down (1));

   % moving to starting place
   set_input_string (starting_header);    call ("locate_header_by_msgid");

   % calling the non-buggy part
   set_input_string (sought_message_ID);  call ("locate_header_by_msgid");
}

% Enhanced version of slrn's locate_header_by_msgid()          % -*- slang -*-

define enhanced_locate_header_by_msgid ();  % needed for recursion!
define enhanced_locate_header_by_msgid () 
{
   % This intrinsic replacement is enhanced in the following ways:
   %
   % (1) It takes an optional message-ID argument:
   %     enhanced_locate_header_by_msgid ([String Message-ID, [Integer p]]);
   %
   % (2) It returns:
   %    -1 if the message-ID was not found in the existing list but *might* be
   %       on the server (I can't tell without getting permission to add the
   %       article to the header list or doing a potentially time-consuming
   %       save-state and restore-state operation).
   %     0 if the message-ID was not found.
   %     1 if the message-ID was found in the existing header list.
   %     2 if the message-ID was found and added to the header list.
   %
   % (3) It only uncollapses a thread when the desired message-ID is inside
   %     a collapsed thread. (functionality from bugfix_locate_header_by_msgid)
   %
   % (4) It takes an optional argument on whether the message-ID can be added
   %     to the list.  If the second argument is non-zero, permission to add
   %     is granted, zero means denied.  The default (if the second argument
   %     is unsupplied) is to grant permission to add.  Permission is not
   %     prompted (in order to remain compatible with the intrinsic) and both
   %     message-ID and permission-bit must be supplied as arguments to make
   %     the permission count.

   variable
     sought_message_ID, permission_to_add = 1,
     usage = sprintf ("Usage: Integer_Type %s ();\n" +
		      "       Integer_Type %s (String_Type message-ID);\n" +
		      "       Integer_Type %s (String_Type message-ID, Integer_Type permission)",
		      _function_name (), _function_name (), _function_name ());

   switch (_NARGS)
     { case (0) :
	sought_message_ID = strtrim (read_mini ("Enter Message-Id", "", ""));
	!if (strlen (sought_message_ID)) return ();
     }
     { case (1) : sought_message_ID = (); }
     { case (2) :
	permission_to_add = ();
	sought_message_ID = ();
     }
     {            error (usage); }

   variable starting_header = extract_article_header ("Message-ID");

   call ("header_bob");

   % The do-while (outer) loop moves the pointer from thread to thread
   % while the for (inner) loop checks the articles in each thread.  The
   % collapse status of the display is only disturbed when the desired
   % message-ID is found inside a thread.

   do
     {
	variable
	  thread_was_collapsed = is_thread_collapsed (),
	  t_size = thread_size (), position;

	for (position = 1; position <= t_size; position++)
	  {
	     if (sought_message_ID == extract_article_header ("Message-ID"))
	       return (1);

	     if (position == 1) uncollapse_thread ();
	     else if (andelse
		       { position == t_size }              % at end of thread
		       { thread_was_collapsed })
	       collapse_thread ();

	     if (position != t_size) () = header_down (1); % next article
	  }
     }
   while (header_down (1));                                % next thread

   eval (sprintf ("() = %s (\"%s\");",                     % recursive call to
		  _function_name (), starting_header));    % starting place
   
   % Here, we have a small problem -- until there is a way to remove a header
   % added to the header list without affecting its header_flags
   % (call("art_xpunge") only works on read headers), we have to check for
   % permission_to_add here.  Ideally, we could check after
   % call("locate_header_by_msgid"), remove the header then return(2).

   !if (permission_to_add) return (-1);

   % calling the non-buggy part -- either the header will not be found
   % (return 0) or it will be found and added to the article list (return 2)

   ERROR_BLOCK { return (0); }                             % don't clear error
   set_input_string (sought_message_ID);
   call ("locate_header_by_msgid");
   return (2);
}

Technical Details
Message-ID: <slrn6ms1dp.lqq.bluemoon@ux6.cso.uiuc.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.mbox.zip!not-for-mail
References: <6kkfqq$l5v$1@charm.magnus.acs.ohio-state.edu>

Show Full Headers
Complete Article Headers
Message-ID: <slrn6ms1dp.lqq.bluemoon@ux6.cso.uiuc.edu>
Subject: Re: slrn needs trn-like thread handling
Date: Fri, 29 May 1998 00:00:00 +0000
From: bluemoon@ux6.cso.uiuc.edu (Dawn Owens-Nicholson)
References: <6kkfqq$l5v$1@charm.magnus.acs.ohio-state.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.mbox.zip!not-for-mail
X-Deja-AN: 357483454
Organization: University of Illinois at Urbana-Champaign
Newsgroups: news.software.readers