Article View: news.software.readers
Article #226387Re: [slrn] Display all threads that contain unread messages
From: John E. Davis
Date: Sat, 27 Sep 2008 17:00
Date: Sat, 27 Sep 2008 17:00
90 lines
3621 bytes
3621 bytes
On Thu, 25 Sep 2008 22:51:18 +0200, Erik Hahn <erik_hahn@replyto.invalid>
wrote:
> The page at http://tinyurl.com/477j9r (Google Cache, it isn't available
> at the original place anymore) claims that you could use a macro to
> display all threads fully that contain at least one unread message. Does
> such a macro already exist or could someone create it (I don't know
> s-lang)?
Below you will find a function that does this from group-mode. I
implemented it in this fashion because querying the server via
message-ids can be expensive and I feel that it is more efficient just
to grab all the available headers from the server and then keep only
those desired.
Use, e.g.,
setkey group select_group_unread_threads "X"
in your .slrnrc file to bind it to "X" in group mode.
FWIW, I prefer to see just the unread articles and manually
reconstruct the thread if I want to see the previously read messages
of the thread.
Good luck, --John
#v+
% Returns 0 if at the last header, otherwise it returns 1
private define header_eobp ()
{
return not header_up (header_down (1));
}
define select_group_unread_threads ()
{
ungetkey ('\r');
set_prefix_argument (1);
if (-1 == select_group ())
return;
uncollapse_threads ();
call ("header_bob");
variable header_flags = Assoc_Type[];
while (not header_eobp ())
{
% Current header starts a thread tree.
variable num_unread = 0;
variable num_processed = 0;
do
{
variable flags = get_header_flags ();
header_flags[extract_article_header ("Message-ID")] = flags;
ifnot (flags & HEADER_READ)
num_unread++;
num_processed++;
}
while (header_down(1) && has_parent ());
if (num_unread)
{
% goto top of thread and undelete it
() = header_up (num_processed-1);
collapse_thread ();
call ("undelete"); % undeletes and moves position down
}
}
% The above loop will not have processed the last header if it was
% not part of a thead. Handle that here.
ifnot (is_thread_collapsed ())
header_flags[extract_article_header ("Message-ID")] = get_header_flags ();
% At this point, threads with at least one unread header is marked as
% unread, and all others are marked as read. Get rid of the others.
call ("expunge");
call ("header_bob");
uncollapse_threads ();
do
{
set_header_flags (header_flags[extract_article_header("Message-ID")]);
}
while (header_down (1));
collapse_threads ();
call ("header_bob");
}
#v-
Technical Details
Message-ID:
<slrngdsplq.hhj.jed@aluche.mit.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.20140922.mbox.gz!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!panix!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mailReferences:
<gbgtk6$5lf$01$1@news.t-online.com>Show Full Headers
Complete Article Headers
Message-ID: <slrngdsplq.hhj.jed@aluche.mit.edu> Subject: Re: [slrn] Display all threads that contain unread messages Date: Sat, 27 Sep 2008 17:00:41 +0000 From: "John E. Davis" <jed@jedsoft.org> References: <gbgtk6$5lf$01$1@news.t-online.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.dca.giganews.com!nntp.giganews.com!postnews.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!panix!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mail Newsgroups: news.software.readers Reply-To: davis@space.mit.edu User-Agent: slrn/pre0.9.9p1-31 (Linux) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 90 NNTP-Posting-Host: ALUCHE.MIT.EDU X-Trace: 1222534841 senator-bedfellow.mit.edu 312 18.75.2.45