Re: View threads with unread posts by default
"J.B. Nicholson-Owens" <[email protected]> Fri, 28 Aug 2015 23:10:22 -0500
| Newsgroups | gmane.network.slrn.user |
|---|---|
| Message-ID | <[email protected]> |
Monte Milanuk wrote:
> I want to see full threads as soon as they contain at least one unread
> article. Can slrn do this?
Here's a macro that attempts to do this. Preserving the thread collapse display could be made to work but it would require considerable more code and increase execution time, particularly on large group with lots of threads. So I didn't do that.
Be warned, this tries to fetch full threads (as you said you wanted) from the server which takes time and makes you wait before you see article mode. Entering article mode with this active will increase the time it takes to enter any group.
In case you don't know how to install this:
1. Save the following to a text file (typically something ending in ".sl" but it's your choice). Let's say you save it to "/home/foo/view_thread_unread.sl".
2. Add:
interpret "/home/foo/view_thread_unread.sl"
to your slrnrc (which is typically stored in ~/.slrnrc on Unix systems).
3. Run slrn normally.
Removing this is just undoing the above steps (mainly commenting out the "interpret" line from your slrnrc).
slrn should load and present you with a list of groups with unread articles. When you enter one slrn will be seen to get parent and child articles for each thread in the set of articles you wanted to read.
I've given this light testing with mostly default settings and my slrn macro hacking days are in the past so it's entirely possible I've overlooked something. I didn't bother checking to see if each thread had at least one unread article because it's likely you're only going to be presented with such threads when you first enter group mode.
Happy hacking.
implements ("view_thread_unread");
static define article_mode_hook ()
{
% 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
% Store starting state for restoration at the end of the
% function.
auto_mark_article_as_read = get_variable_value ("auto_mark_article_as_read"),
sorting_method = get_variable_value ("sorting_method"),
starting_article = extract_article_header ("Message-ID"),
article_was_visible = (_is_article_visible () & 1),
% Temporary thread size counter.
t = 0;
% We don't want articles being marked read by side effects from
% intrinsics we call.
set_integer_variable ("auto_mark_article_as_read", 0);
% Also, we want a threaded sorting order for the logic of this
% function to work well. "Thread, then sort by subject" is as good
% as any other threading option.
set_integer_variable ("sorting_method", 3);
call ("article_bob");
do
{
collapse_thread ();
% Fetch all of this threads available articles from the
% server. The get_parent_header intrinsic has a side effect of
% collapsing all threads except for the current thread.
set_prefix_argument (1);
call ("get_parent_header");
t = thread_size ();
% Move to the end of this thread.
ifnot ((t - 1) == header_down (t - 1))
{
% If this attempt failed, collapse the thread and we'll
% move to the next thread at the end of the loop.
collapse_thread ();
}
}
% Move to next thread.
while (header_down (1));
% Replace cursor at starting article.
() = locate_header_by_msgid (starting_article, 0);
% Restore article visibility.
if (article_was_visible xor (_is_article_visible () & 1)) call ("hide_article");
% Restore variable settings.
set_integer_variable ("auto_mark_article_as_read", auto_mark_article_as_read);
set_integer_variable ("sorting_method", sorting_method);
}
switch (register_hook ("article_mode_hook", "view_thread_unread->article_mode_hook"))
{ case 0: throw ("Can't register to article_mode_hook()!"); }
{ case 2: throw ("view_thread_unread->article_mode_hook() should not have been already registered!"); }
{ case 3: throw ("Can't find view_thread_unread->article_mode_hook()!"); }
------------------------------------------------------------------------------