🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
10 messages
10 total messages Started by J.B. Nicholson Thu, 03 Aug 2017 05:47
[slrn] Fetch new news from article mode
#262248
Author: J.B. Nicholson
Date: Thu, 03 Aug 2017 05:47
173 lines
7218 bytes
Here's a macro I wrote which makes slrn appear to fetch new articles
from article mode. To present that illusion the macro marks all
articles unread, records thread collapse status and header flags for
all articles, quits to group mode, fetches the new articles, and
re-enters the same group leaving all of the headers and thread display
as they were before leaving article mode. This is intended to give the
illusion that new articles simply 'arrived' in article mode.

How to use this: Save the following (not including the #v+ and #v-
verbatim marks) into a file (perhaps ~/refresh_reenter_group.sl) and
add:

  interpret "/path/to/refresh_reenter_group.sl"

to your slrnrc (adjusting the path to where you saved it, of
course). Quit slrn, run slrn (you should see a message about loading
this macro file), and enter a newsgroup. When you want to get new
articles, press "G" to make slrn get new articles without appearing to
leave article mode.

If this is long enough to be copyrightable, consider it licensed under
the GNU General Public License version 2 or later. Please feel free to
run, inspect, share, and modify.

Enjoy.



#v+
public define refresh_reenter_group ()
{
   % Appears to refresh groups (fetch new news) without leaving article mode
   % and without removing read articles from the article mode list (in order
   % to preserve the illusion that the function never left article mode).

   if (is_group_mode ())
     throw UsageError, _function_name () + " only works in article mode!";

   variable
     % Settings to be changed and restored before this function
     % returns. This must be defined here to avoid a problem parsing the
     % EXIT_BLOCK.
     starting_query_read_group_cutoff = get_variable_value ("query_read_group_cutoff"),
     prefix_arg = get_prefix_arg();

   % Avoid passing prefix arguments to intrinsic functions.
   % Record the prefix argument, reset the prefix argument, and
   % restore the prefix argument at the end (in the EXIT_BLOCK).
   reset_prefix_arg();
   EXIT_BLOCK
     {
	% Restore the state previously modified.
	set_integer_variable ("query_read_group_cutoff", starting_query_read_group_cutoff);
	if (prefix_arg != -1) set_prefix_argument (prefix_arg);
     }

   variable     
     % Initialized with useful values.
     starting_article = extract_article_header ("Message-ID"),
     starting_newsgroup = current_newsgroup (),
     article_was_visible_and_current = (_is_article_visible () == 3),

     % Initialized to indicate type.
     thread_collapse_status = Assoc_Type[Integer_Type],
     thread_was_collapsed = 0,
     article_was_zoomed = is_article_window_zoomed (),
     i = 0,
     t = 0,
     message_ID = "",
     header_flags = 0,
     
     % Used to track article flags (read, starred, etc.).
     message_ID_flags = Assoc_Type[Integer_Type];

   % Store collapse status for unread articles, mark every article
   % unread, and store header flags.
   call ("header_bob");
   do
     {
	t = thread_size ();
	thread_was_collapsed = is_thread_collapsed ();

	uncollapse_thread ();
	for (i = 1; i <= t; i++)
	  {
	     message_ID = extract_article_header ("Message-ID");
	     header_flags = get_header_flags ();
	     
	     % Track:
	     % - collapse status for threads with more than 1 article
	     %   because single-article threads are uncollapsed by
	     %   default (is_thread_collapsed() returns 0 for single-article
	     %   threads) which would create an uncollapsed thread if a
	     %   followup article arrives in that thread. That uncollapsed
	     %   thread would break the illusion of preserving thread
	     %   collapse status,
	     %
	     % - header flags for articles with nonzero header flags.
	     if (t > 1) thread_collapse_status[message_ID] = thread_was_collapsed;
	     if (header_flags) message_ID_flags[message_ID] = header_flags;

             % Reset the score to 0 and mark the article unread. slrn will
	     % re-score the article again upon re-entering this group.
	     set_header_score (0);
	     set_header_flags (header_flags () & ~HEADER_READ);

	     % We care about the thread display because the user
	     % might be running something in a hook that tracks thread
	     % collapse status.
	     if (i != t) () = header_down (1);
	     else if (thread_was_collapsed) collapse_thread ();
	  }
     }
   % Go to the next thread.
   while (header_down (1));

   % Quit to group mode, refresh the newsgroup list, and re-enter the
   % newsgroup we were in putting us back in article mode.
   try
     {
	call ("quit");
	call ("refresh_groups");
	set_input_string (starting_newsgroup);
	call ("add_group");
	set_integer_variable ("query_read_group_cutoff", 0);
	call ("select_group");
     }
   catch AnyError:
     {
	if (is_group_mode ())
	  {
	     throw InternalError, "Something went horribly wrong and we could not re-enter " + starting_newsgroup;
	  }
     }

   % Restore the nonzero header flags.
   foreach message_ID,header_flags (message_ID_flags) using ("keys", "values")
     {
	ifnot (locate_header_by_msgid (message_ID, 0)) continue;
	set_header_flags (header_flags);
     }
   
   % Restore the thread display.
   foreach message_ID,thread_was_collapsed (thread_collapse_status) using ("keys", "values")
     {
	ifnot (locate_header_by_msgid (message_ID, 0)) continue;
	if (thread_was_collapsed) collapse_thread ();
	else uncollapse_thread ();
     }

   % Try to put the cursor where it was...
   ifnot (locate_header_by_msgid (starting_article, 0))
     {
	return ();
     }

   % ...and restore the article view.
   if (article_was_visible_and_current != (_is_article_visible () & 1))
     {
	call ("hide_article");
     }

   % Zooms the article window if the article window was showing
   % the article.
   if ((_is_article_visible () & 1)
       && article_was_zoomed
       && (is_article_window_zoomed () == 0))
     {
	call ("zoom_article_window");
     }
}
definekey ("Global->refresh_reenter_group", "G", "article");
#v-
Re: [slrn] Fetch new news from article mode
#262260
Author: Lewis
Date: Sat, 12 Aug 2017 17:29
9 lines
1447 bytes
In message <slrnoo5e7v.51k.jbn@forestfield.org> J.B. Nicholson <jbn@forestfield.org> wrote:
> Here's a macro I wrote which makes slrn appear to fetch new articles
> from article mode.

Thank you for this, it's a feature I've long wanted slrn to have, and
your macro (so far) works perfectly.

-- 
Cecil is made of blood and unfinished leather
Re: [slrn] Fetch new news from article mode
#262263
Author: J.B. Nicholson
Date: Sat, 12 Aug 2017 23:34
7 lines
1512 bytes
Lewis <g.kreme@gmail.com.dontsendmecopies> wrote:
> Thank you for this, it's a feature I've long wanted slrn to have, and
> your macro (so far) works perfectly.

You're welcome; I've been adding some more features to it so it works
faster and preserves more state from article mode. I'll post that
update when I've had a chance to debug it some more.
Re: [slrn] Fetch new news from article mode
#262262
Author: andrew
Date: Sat, 12 Aug 2017 23:53
19 lines
1637 bytes
On 2017-08-12, J.B. Nicholson <jbn@forestfield.org> wrote:
> Lewis <g.kreme@gmail.com.dontsendmecopies> wrote:
>> Thank you for this, it's a feature I've long wanted slrn to have, and
>> your macro (so far) works perfectly.
>
> You're welcome; I've been adding some more features to it so it works
> faster and preserves more state from article mode. I'll post that
> update when I've had a chance to debug it some more.

If you are happy with the eventual final version can I add this version
to the slrn web site? There is a section:

http://slrn.sourceforge.net/macros.html#download

where in the past I have added macros...

Andrew
-- 
Do you think that's air you're breathing?
Re: [slrn] Fetch new news from article mode
#262264
Author: J.B. Nicholson
Date: Sun, 13 Aug 2017 00:02
5 lines
1415 bytes
andrew <andrew@skamandros.invalid> wrote:
> If you are happy with the eventual final version can I add this
> version to the slrn web site?

Sure, go ahead. Thanks!
[slrn] refresh_reenter_group-1.0 is released
#262265
Author: J.B. Nicholson
Date: Tue, 29 Aug 2017 03:56
16 lines
1853 bytes
I <jbn@forestfield.org> wrote:
> I've been adding some more features to it so it works faster and
> preserves more state from article mode. I'll post that update when
> I've had a chance to debug it some more.

Please check out

  https://forestfield.org/slrn/refresh_reenter_group-1.0.tar.gz

and see if it works a little better now that the macro uses a slrn's
intrinsic function to get more the job done (namely, marking all the
messages as unread before leaving the group). If there's something
wrong with the macro, please let me know.

It's licensed under the GNU GPL v2 or later, so run, share, inspect,
modify, and enjoy.
Re: [slrn] refresh_reenter_group-1.0 is released
#262267
Author: Phil Boutros
Date: Thu, 31 Aug 2017 19:04
35 lines
2301 bytes
J.B. Nicholson <jbn@forestfield.org> wrote:
> I <jbn@forestfield.org> wrote:
>> I've been adding some more features to it so it works faster and
>> preserves more state from article mode. I'll post that update when
>> I've had a chance to debug it some more.
>
> Please check out
>
>   https://forestfield.org/slrn/refresh_reenter_group-1.0.tar.gz

    Very nice!  Minor nitpick:  The name used in the tarball and in
the documentation is inconsistent (dashes vs underscores in part of
the name.)  Took me a few minutes wondering why slrn complained it
couldn't find the file I was asking it to interpret in the .slrnrc!

From the script itself:

%  2. Edit your slrnrc to load this file and bind the function to a
%     key by adding:
%     
%       interpret "/path/to/.slrn/refresh-reenter-group-1.0.sl"
%       setkey article "refresh_reenter_group->refresh_reenter_group"
%       "G"

    Except the file in the tarball is refresh_reenter_group-1.0.sl, so
copying those two lines fails...

    A very minor criticism, but it could hurt some of the less
experienced users.


Phil
-- 
AH#61  Wolf#14  BS#89  bus#1  CCB#1  SENS  KOTC#4
philb@philb.ca  http://philb.ca
Re: [slrn] refresh_reenter_group-1.0 is released
#262266
Author: J.B. Nicholson
Date: Thu, 31 Aug 2017 22:21
9 lines
1638 bytes
Phil Boutros <philb@philb.ca> wrote:
>     Except the file in the tarball is refresh_reenter_group-1.0.sl, so
> copying those two lines fails...
>
>     A very minor criticism, but it could hurt some of the less
> experienced users.

Thanks for pointing it out; this is fixed and uploaded to
https://forestfield.org/slrn/refresh_reenter_group-1.1.tar.gz
Re: [slrn] refresh_reenter_group-1.0 is released
#262268
Author: Lewis
Date: Sun, 03 Sep 2017 04:47
20 lines
1960 bytes
In message <slrnoq9pfn.ecp.jbn@forestfield.org> J.B. Nicholson <jbn@forestfield.org> wrote:
> I <jbn@forestfield.org> wrote:
>> I've been adding some more features to it so it works faster and
>> preserves more state from article mode. I'll post that update when
>> I've had a chance to debug it some more.

> Please check out

>   https://forestfield.org/slrn/refresh_reenter_group-1.0.tar.gz

Not Found

The requested URL /slrn/refresh_reenter_group-1.0.tar.gz was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


-- 
'I'll tell you this!' shouted Rincewind. 'I'd rather trust me than
history! Oh, shit, did I just say that?'
Re: [slrn] refresh_reenter_group-1.0 is released
#262269
Author: J.B. Nicholson
Date: Sun, 03 Sep 2017 06:10
32 lines
2527 bytes
Lewis <g.kreme@gmail.com.dontsendmecopies> wrote:
> The requested URL /slrn/refresh_reenter_group-1.0.tar.gz was not
> found on this server.

Thanks for pointing that out. Try

  https://forestfield.org/slrn/refresh_reenter_group.tar.gz

instead. I just added two lines that resulted in keeping the position
of the text in the article pager, furthering the illusion that slrn is
getting new news from article mode. I noticed the article kept jumping
back to the top of the article when I fetched new news from article
mode. Now the article stays put and I can keep reading from where I
left off.

Since you mention that error, there's got to be a better way to let me
update this when something strikes me while still letting people get
URLs that work. I'll make

  https://forestfield.org/slrn/refresh_reenter_group.tar.gz

always point to the latest and then you can get the version from the
same URL. This seems to work for me but if it doesn't work for you
(slrn users) let me know.

Otherwise, you can reload

  https://forestfield.org/slrn/

and see what's there. Maybe I'll turn that into a directory listing
instead of a proper webpage with plain language descriptions so I
don't have to edit that page again.
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