🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #69536

Re: [slrn] thread_size() & single article

#69536
From: cedric
Date: Fri, 22 Dec 2000 06:54
113 lines
5111 bytes
[...]

J.B. Nicholson-Owens wrote:
>
>> I'm using an odd sorting number (7) to sort by threads.
>> And that's my problem: I can't distinguish an article that has no children
>> from one that has no children nor parents.
>
>Okay, now we're getting somewhere.  Visually speaking (meaning you're only
>concerned with the articles in the header list), here's how to determine the
>difference between an article without children and an article without
>children or parents: (all of this assumes you're in article mode, of course)
>
>  In a threaded sorting method, thread_size() will return 1 for an article
>  without children.  That's all there is to that.  If you want to determine
>  this in an unthreaded sorting method, that's more involved.
>
>  Regardless of the sorting method
>
>    strchop (extract_article_header ("References"), ' ', 0)[-1]
>
>  is the message-ID of the current article's parent.  You can pass this
>  message-ID to locate_header_by_msgid() to determine if that article is in
>  the header list.  You'll want to pass 0 as the second argument to
>  locate_header_by_msgid() so you don't make slrn attempt to insert the
>  article in the header list.  Also if the article is found, the cursor will
>  move to that parent article.  So you'll have to compensate for this cursor
>  movement.
>
>In other words:
>
>#v+
>   variable descendants = thread_size () - 1;
>#v-
>
>is one quick way to check for descendant articles.  The current article has
>'descendants' number of descendant articles (which means if descendants is
>non-zero, the article has at least one child).
>
>#v+
>   variable
>      previous_message_id = extract_article_header ("Message-ID"),
>      parent = strchop (extract_article_header ("References"), ' ', 0)[-1];
>
>   if (andelse { parent != "" } { locate_header_by_msgid (parent, 0) })
>     {
>        % Now the cursor is at the parent article.
>        % .
>	% . do something with that article here
>	% .
>	% Return the cursor to where we were.
>	() = locate_header_by_msgid (previous_message_id, 0);
>     }
>   else
>     {
>	% The article at the cursor has no parent article in the header list.
>	% This means either the current article has no logical parent or the
>	% current article's parent article is not in the header list.  Since
>	% you didn't distinguish between these two states in your article (to
>	% my understanding), I figured this distinction didn't really matter
>	% for your purposes.
>     }
>#v-
>
>is one quick way to check for parent articles without moving the cursor.

That's exactly what I was looking for...

But it happened to me to have some broken threads (having a grand-parent but
not THE parent) so I completed a little your macro so that I can know if an
ancestor of an article is present(visually speaking):

#v+
  variable previous_message_id = extract_article_header ("Message-ID");
  variable parents,p_id,p_size;
  variable i=0;

  do
  {
    i--;
    parents = strchop (extract_article_header ("References"), ' ', 0);
    p_id = parents[i];
    p_size = length (parents);
  }
  while (andelse {i > -p_size } { p_id != "" } { not ( locate_header_by_msgid
       ( p_id, 0 )) } );

  if (andelse { p_id != "" } { locate_header_by_msgid (p_id, 0) })
  {
    % the article has a parent
    () = locate_header_by_msgid (previous_message_id, 0);
  }
  else
  {
    % this is an orphan article or an original post
  }
#v-

Maybe reading the length of the array at each loop is not very efficient if the
thread is huge... It would certainly be better to query this at the begining.
>
>Happy newsreading.

Thank you very much for your help. No doubt that I will have a "happy
newsreading"! I discovered slrn for less than a week, but I've already fallen
in love with the fantastic possibility to configure his behaviour with a
language :-)

  Cedric.

PS: are #v+ and #v- a standard way for newsreaders to indicate emphazised
portions of text?
Technical Details
Message-ID: <40uu19.va2.ln@cd24.news.free.fr>
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!supernews.google.com!sn-xit-02!supernews.com!216.227.56.88.MISMATCH!telocity-west!TELOCITY!fr.clara.net!heighliner.fr.clara.net!grolier!proxad.net!feeder2.proxad.net!nnrp2.proxad.net.POSTED!cedricduval
References: <0ruq19.1q3.ln@127.0.0.1> <slrn9430e5.8v.jbn@next.forestfield.org> <n47s19.4d4.ln@127.0.0.1> <slrn943hbu.8v.jbn@next.forestfield.org>

Show Full Headers
Complete Article Headers
Message-ID: <40uu19.va2.ln@cd24.news.free.fr>
Subject: Re: [slrn] thread_size() & single article
Date: Fri, 22 Dec 2000 06:54:42 GMT
From: cedricduval@free.fr (cedric)
References: <0ruq19.1q3.ln@127.0.0.1> <slrn9430e5.8v.jbn@next.forestfield.org> <n47s19.4d4.ln@127.0.0.1> <slrn943hbu.8v.jbn@next.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.mbox.zip!supernews.google.com!sn-xit-02!supernews.com!216.227.56.88.MISMATCH!telocity-west!TELOCITY!fr.clara.net!heighliner.fr.clara.net!grolier!proxad.net!feeder2.proxad.net!nnrp2.proxad.net.POSTED!cedricduval
Newsgroups: news.software.readers
User-Agent: slrn/0.9.6.2 (Linux)
Lines: 112
NNTP-Posting-Host: 213.228.50.100
X-Complaints-To: abuse@proxad.net
X-Trace: nnrp2.proxad.net 977468082 213.228.50.100 (Fri, 22 Dec 2000 07:54:42 CET)
NNTP-Posting-Date: Fri, 22 Dec 2000 07:54:42 CET
Organization: Guest of ProXad - France