interesting threading question

Tavis Ormandy <[email protected]> Fri, 18 Jun 2021 04:26:20 -0000 (UTC)
Newsgroups gmane.network.slrn.user
Message-ID <[email protected]>
Someone asked an interesting question on news.software.readers, how do
you sort articles by most recently active thread?

There is sorting_method 9, but that sorts by thread *parent* date, not the date
of the most recent reply.

I almost replied "Sorry, not possible", but then realized how to do it - you
can make any sorting method you want by setting temporary scores in
a article_mode_startup_hook!

Here is my solution:

define score_child_date ()
{
    variable score = Assoc_Type[Int_Type, 0];
    variable flags = Assoc_Type[Int_Type, 0];
    variable mid;
    variable num = 0;

    % Sort by date, most recent last, no threads.
    set_integer_variable("sorting_method", 10);
    sort_by_sorting_method();

    header_bob();

    % Now visit every mail, save it's current score
    % and set it's score to it's position in the sorted list.
    do {
        mid = extract_article_header("Message-ID");
        score[mid] = get_header_score();
        flags[mid] = get_header_flags();
        set_header_score(num);

        % It turns out changing the score updates flag, so fix those
        % immediately.
        set_header_flags(flags[mid]);
        num = num + 1;
    } while (header_down(1) == 1);
    % Now sort by score, threaded.
    set_integer_variable("sorting_method", 5);
    sort_by_sorting_method();
    uncollapse_threads();

    header_bob();

    % Revisit every mail, fixing the score.
    do {
        mid = extract_article_header("Message-ID");
        set_header_score(score[mid]);
        set_header_flags(flags[mid]);
    } while (header_down(1) == 1);

    header_bob();
    collapse_threads();
}

() = register_hook("article_mode_startup_hook", "score_child_date");

If you want to use it, just add something like this to your slrnrc:

interpret "util.sl"
interpret "/path/to/this/macro.sl"

Tavis.

-- 
 _o)            $ lynx lock.cmpxchg8b.com
 /\\  _o)  _o)  $ finger [email protected]
_\_V _( ) _( )  @taviso