🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #257753

Re: Refreshing SLRN heders while viewing newsgroup?

#257753
From: J.B. Nicholson-Owens
Date: Sat, 24 May 2014 02:41
119 lines
5951 bytes
I <jbn@forestfield.org> wrote:
> Here's a version that should preserve the article visibility and
> zooming [...]

Here's a version which adds the ability to preserve the thread display
and retains articles marked as read when you fetch new articles. This
change more effectively conveys the illusion that you can update the
article list from article mode. Install StickyTags to save/restore *'d
articles as well (see http://forestfield.org/slrn/#stickytags for
StickyTags).

#v+
define refresh_reenter_group () 
{
   if (is_group_mode ())
     throw UsageError, _function_name () + " only works in article mode!";

   % We don't want any prefix arguments to interfere with any call()s
   % we make. So we record the prefix argument, reset the prefix
   % argument, and restore the prefix argument at the end (in the
   % EXIT_BLOCK).
   variable prefix_arg = get_prefix_arg();
   reset_prefix_arg();
   EXIT_BLOCK
     {
	% Restore the prefix argument.
	if (prefix_arg != -1) set_prefix_argument (prefix_arg);
     }

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

     % Initialized later and generally 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 = "",
     message_ID_set = Assoc_Type[Integer_Type];

   % Store collapse status for unread articles. Threads with all-read
   % articles will disappear when we re-enter the group because read
   % articles won't be around to set collapse status on.
   call ("header_bob");
   do
     {
	t = thread_size ();
	thread_was_collapsed = is_thread_collapsed ();
	message_ID = "";
	message_ID_set = Assoc_Type[Integer_Type];

	uncollapse_thread ();
	for (i = 1; i <= t; i++)
	  {
	     % We track collapse status for all articles.
	     thread_collapse_status[extract_article_header ("Message-ID")] = thread_was_collapsed;

	     % We care about how we leave the thread 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.
   call ("quit");
   call ("refresh_groups");
   set_input_string (starting_newsgroup);
   call ("add_group");
   call ("select_group");
   if (is_group_mode ())
     throw InternalError, "Something went horribly wrong and we could not re-enter " + starting_newsgroup;

   % Working around a bug here: normally we'd restore the thread
   % display THEN replace the cursor where it was (switching the two
   % next stanzas). But locate_header_by_msgid(m, 1) collapses the
   % thread display. Therefore we restore the thread display /after/
   % all locate_header_by_msgid(m, 1) calls.

   % Put the cursor where it was and restore the article view only if
   % the article wasn't already in the header list.
   if (locate_header_by_msgid (starting_article, 1))
     {
	% Shows/hides the article if that's what we were looking at before.
	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");
     }

   % Fetch from the server all of the articles that were in the
   % article list. This should help convey the illusion that the only
   % effect this macro has is adding new articles to the article list.
   foreach message_ID (thread_collapse_status) using ("keys")
     () = locate_header_by_msgid (message_ID, 1);

   % Restore the thread display and reposition the cursor on the
   % article we were on when this macro began.
   foreach message_ID,thread_was_collapsed (thread_collapse_status) using ("keys", "values")
     {
	() = locate_header_by_msgid (message_ID, 0);
	if (thread_was_collapsed) collapse_thread ();
	else uncollapse_thread ();
     }
   () = locate_header_by_msgid (starting_article, 0);
}
definekey ("Global->refresh_reenter_group", "G", "article");
#v-
Technical Details
Message-ID: <slrnlo01nh.pcf.jbn@forestfield.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.20140922.mbox.gz!border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
References: <53590b16$0$9244$c3e8da3$9f400e27@news.astraweb.com> <slrnllj3ul.a2b.jbn@forestfield.org> <slrnlljnha.g4m.jbn@forestfield.org>

Show Full Headers
Complete Article Headers
Message-ID: <slrnlo01nh.pcf.jbn@forestfield.org>
Subject: Re: Refreshing SLRN heders while viewing newsgroup?
Date: Sat, 24 May 2014 02:41:53 +0000
From: "J.B. Nicholson-Owens" <jbn@forestfield.org>
References: <53590b16$0$9244$c3e8da3$9f400e27@news.astraweb.com> <slrnllj3ul.a2b.jbn@forestfield.org> <slrnlljnha.g4m.jbn@forestfield.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.20140922.mbox.gz!border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
Newsgroups: news.software.readers
Organization: albasani.net
Lines: 119
X-Trace: news.albasani.net
 ZjwtTwRU3OnFoGOPVZLyIJXww/R2fDPjyPea2OGlkJKg5V9LE/pFoOe9dMUpoQg8ngv+Fs3pDgwP7Du6LXwi+Q==
NNTP-Posting-Date: Sat, 24 May 2014 02:41:53 +0000 (UTC)
Injection-Info: news.albasani.net;
 logging-data="0xWxsO05w1fJqdqmBAnvTuuZmVyodXycUN7xalSvK/lFPhkkCbkFOLoNEf2sDE3AXffIWAw3ft1pYLaJoAfOWt3qlbKBrO3RtOsT9w/m84aDOZYhWMnt9wmmVLQVD3Gc";
 mail-complaints-to="abuse@albasani.net"
User-Agent: slrn/1.0.1 (Linux)
Cancel-Lock: sha1:t1ECPHzzBPSgLrfOvHtOEa4WFZQ=
X-Original-Bytes: 5638