On 2021-06-17, Jay wrote:
> Thanks. That doesn't quite work; it still sorts by the date of the highest
> ancestor of a thread, not by the most recent message in any given thread.
Ah, I don't think that's possible.
There is no sorting hook, so you can't override how articles are
compared with macros, it's all hardcoded.
It would be nice if you could write an article_mode_hook that changes
the date, but you can't do anything like replace_article() then AFAIK.
Wait... LOL.. just as I was writing this reply saying it was impossible,
I realized how you could do it. It's a weird solution, so be prepared :-)
You can't alter articles in article_mode_hook, but you can adjust the
score. What if you temporarily set the score of each article to the
unixtime it was sent, sort it, then change it back? Slrn automatically
propogates the highest score to the thread, then you can sort by score before
reapplying the old scores.
Believe it or not, I think this works!
Try the macro below.
Tavis.
define score_child_date ()
{
variable score = Assoc_Type[Int_Type, 0];
variable flags = Assoc_Type[Int_Type, 0];
variable date;
variable meth;
variable mid;
uncollapse_threads();
header_bob();
do {
date = extract_article_header("Date");
mid = extract_article_header("Message-ID");
score[mid] = get_header_score();
flags[mid] = get_header_flags();
set_header_score(datestring_to_unixtime(date));
} while (header_down(1) == 1);
meth = get_variable_value("sorting_method");
set_integer_variable("sorting_method", 5);
sort_by_sorting_method();
uncollapse_threads();
set_integer_variable("sorting_method", meth);
header_bob();
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");