Thread View: news.software.readers
3 messages
3 total messages
Started by Dawn Owens-Nicholson
Tue, 15 Sep 1998 00:00
[slrn] Looptastic -- looping macros for slrn
Author: Dawn Owens-Nicholson
Date: Tue, 15 Sep 1998 00:00
Date: Tue, 15 Sep 1998 00:00
719 lines
22301 bytes
22301 bytes
Have you ever wanted some keys to loop around the group or article displays?
Now you can with this macro set.
% Looping around slrn's group/article lists % -*- mode: slang; mode: fold -*-
%
% Copyright 1998 J.B. Nicholson-Owens
% Author: J.B. Nicholson-Owens
% Title: Looptastic.sl
% Version: 2.0
% Requires: slrn 0.9.5.3 or greater, S-Lang 1.0 or greater
#iffalse % Documentation
Have you ever wanted some keys to loop around the group or article displays?
Now you can with this macro set.
This is the second version of this functionality, I released a similar set
of macros a while ago for use with S-Lang 0.x. This version is
self-contained (you don't need any other S-Lang files but this macro to use
it).
To install this macro set:
(1) Save a copy of this file (or article) as "Looptastic.sl" somewhere so
slrn can find it. Your home directory will do if you don't have a
better place for it.
(2) Append the following lines to your slrn.rc ($HOME/.slrnrc on Unix) to
make slrn load this file and set up some keys to access the functions:
interpret "Looptastic.sl"
setkey article "looptastic_skip_to_next_group" "N"
setkey article "looptastic_skip_to_prev_group" "P"
setkey article "looptastic_next" "n"
setkey article "looptastic_prev" "p"
setkey article "looptastic_delete" "d"
setkey article "looptastic_undelete" "u"
setkey article "looptastic_up" "^P"
setkey article "looptastic_up" "\e[A"
setkey article "looptastic_up" "\eOA"
setkey article "looptastic_up" "^(ku)"
setkey article "looptastic_down" "^(kd)"
setkey article "looptastic_down" "^N"
setkey article "looptastic_down" "\e[B"
setkey article "looptastic_down" "\eOB"
setkey article "looptastic_toggle_header_tag" "*"
setkey article "looptastic_tag_header" "#"
setkey article "looptastic_scroll_dn" " "
setkey article "looptastic_next_high_score" "!"
setkey group "looptastic_subscribe" "s"
setkey group "looptastic_unsubscribe" "u"
If your terminfo/termcap files contain information about the escape
sequences that your arrow keys generate, you only need the following
looptastic_up/looptastic_down keybindings:
setkey article "looptastic_up" "^(ku)"
setkey article "looptastic_down" "^(kd)"
(3) Quit slrn and restart slrn. The keys you mapped to Looptastic macros
will take effect.
Optional steps:
(1) There is a preference that controls how looptastic_prev() will work when
there are no more articles to read. call("prev") behaves differently
than call("next") in that prev doesn't skip to the previous group with
unread articles, whereas next will. The default behavior is to do what
call("prev") would normally do.
By putting the following line in a preferences file (perhaps one called
"my_preferences.sl" stored in your homedir or somewhere where slrn will
find it):
variable looptastic_strict_compatibility = 1;
If you decide to do this, include an additional line to make slrn load
the preferences file:
interpret "my_preferences.sl"
(2) prev_high_score() does the same thing as the intrinsic next_high_score
(bound to "!" by default) in reverse--it goes backwards through the
header list and stops at high scoring articles. If you want this
functionality, you could include the following line in your slrn.rc
with the other setkey lines for this macro set:
setkey article "prev_high_score" "\e!"
If you'd also like the looping version of this key, you could include:
setkey article "looptastic_prev_high_score" "@"
This will let you go backwards through the high scoring articles with the
"@" key.
Now you should be able to start (or restart) slrn and see the cursor loop
around the group and article lists as you read news. Feel free to use other
keybindings (or to not use all of them). The point is the looping
functionality is in the looptastic_* functions (i.e., looptastic_next() is
equivalent to call("next") except looptastic_next() loops).
To remove this macro set:
(1) Comment out or delete the interpret and setkey lines from your slrn.rc:
% interpret "Looptastic.sl"
% setkey article "looptastic_skip_to_next_group" "N"
% setkey article "looptastic_skip_to_prev_group" "P"
% setkey ...
If you did the optional step and changed the preference regarding
looptastic_prev, be sure to comment or remove the "variable" line as well.
You might also want to comment out or remove loading the "my_prefs.sl"
file.
(3) Quit slrn and restart slrn. The keys you mapped to looping macros will
revert back to whatever they're bound to now (possibly doing nothing
because they're not bound to anything).
#endif
!if (is_defined ("looptastic_strict_compatibility"))
eval ("variable looptastic_strict_compatibility = 1;");
define find_next_group_from (starting_newsgroup) % should be file-local %{{{
{
% Starting at the supplied group, find the next group with apparently
% unread articles that is not the starting group. Loop.
while (current_newsgroup () != starting_newsgroup)
() = group_search (starting_newsgroup);
!if (group_down_n (1)) call ("bob");
USER_BLOCK0
{
do
{
if (current_newsgroup () == starting_newsgroup) return (0);
if (group_unread ()) return (1);
}
while (group_down_n (1));
}
X_USER_BLOCK0 ();
call ("bob");
X_USER_BLOCK0 ();
}
%}}}
define looptastic_skip_to_next_group () %{{{
{
% This should be an unpromptable skip -- a /hard/ skip -- to the next group.
% But this should find a group with unread articles, allowing an all-killed
% newsgroup to abort this macro (via error()).
if (is_group_mode ())
error (_function_name () + " doesn\'t work in group mode.");
variable starting_group = current_newsgroup ();
call ("skip_to_next_group");
if (is_group_mode ()) % skip_to_next_group failed
{
if (find_next_group_from (starting_group)) call ("select_group");
else
{
if (looptastic_strict_compatibility) call ("eob");
else message ("No next newsgroup.");
}
}
}
%}}}
define find_prev_group_from (starting_newsgroup) % should be file-local %{{{
{
% Starting at the supplied group, find the previous group with apparently
% unread articles that is not the starting group. Loop.
while (current_newsgroup () != starting_newsgroup)
() = group_search (starting_newsgroup);
!if (group_up_n (1)) call ("eob");
USER_BLOCK0
{
do
{
if (current_newsgroup () == starting_newsgroup) return (0);
if (group_unread ()) return (1);
}
while (group_up_n (1));
}
X_USER_BLOCK0 ();
call ("eob");
X_USER_BLOCK0 ();
}
%}}}
define looptastic_skip_to_prev_group () %{{{
{
% This should be an unpromptable skip -- a /hard/ skip -- to the prev group.
% But this should find a group with unread articles, allowing an all-killed
% newsgroup to abort this macro (via error()).
if (is_group_mode ())
error (_function_name () + " doesn\'t work in group mode.");
variable starting_group = current_newsgroup ();
call ("skip_to_prev_group");
if (is_group_mode ()) % skip_to_prev_group failed
{
if (find_prev_group_from (starting_group)) call ("select_group");
else
{
if (looptastic_strict_compatibility) call ("bob");
else message ("No previous newsgroup.");
}
}
}
%}}}
define looptastic_next () %{{{
{
if (is_group_mode ())
error (_function_name + " doesn\'t work in group mode.");
if (header_next_unread ()) % common call("next") action
{
() = header_up (1);
call ("next");
}
else
{
variable
starting_article = extract_article_header ("Message-ID"),
starting_group = current_newsgroup ();
call ("header_bob");
if (extract_article_header ("Message-ID") == starting_article)
{
call ("next");
if (is_group_mode ())
{
if (find_next_group_from (starting_group))
call ("select_group");
}
return ();
}
if (get_header_flags () & HEADER_READ) % find next unread header
{
call ("next");
if (andelse
{ is_group_mode () }
{ find_next_group_from (starting_group) })
call ("select_group");
return ();
}
if (andelse
{ get_variable_value ("query_next_article") }
{ get_next_art_pgdn_action () == 2 })
{
set_input_string (starting_article);
call ("locate_header_by_msgid");
message ("At the end of the article, press RETURN for next unread article.");
variable key = getkey ();
!if (orelse { key == '\n' } { key == '\r' }) return ();
call ("header_bob");
}
if (is_article_visible ()) call ("scroll_dn");
}
}
%}}}
define looptastic_scroll_dn () %{{{
{
variable key = 0;
switch (get_next_art_pgdn_action ())
{ case (-1) : error (_function_name () + " doesn\'t work in group mode");}
{ case (2) :
variable
message_ID = extract_article_header ("Message-ID"),
thread_was_collapsed = is_thread_collapsed ();
if (get_variable_value ("query_next_article"))
{
message ("At end of article, press SPACE for next unread article.");
update ();
key = getkey ();
if (key != ' ')
{
ungetkey (key);
return ();
}
}
call ("header_bob");
if (get_header_flags () & HEADER_READ)
{
if (header_next_unread ())
{
call ("scroll_dn");
return ();
}
else
{
if (get_variable_value ("query_next_group"))
{
set_input_string (message_ID);
call ("locate_header_by_msgid");
if (thread_was_collapsed) collapse_thread ();
message ("No following unread articles. Press RETURN for next group.");
update ();
key = getkey ();
!if (orelse { key == '\n' } { key == '\r' })
{
ungetkey (key);
return ();
}
}
looptastic_skip_to_next_group ();
}
}
else call ("scroll_dn"); % select article
}
{ call ("scroll_dn"); }
}
%}}}
define looptastic_subscribe () %{{{
{
!if (is_group_mode ())
error (_function_name () + " doesn\'t work in article mode!");
variable starting_group = current_newsgroup ();
call ("subscribe");
if (current_newsgroup () == starting_group) call ("bob");
}
%}}}
define looptastic_unsubscribe () %{{{
{
!if (is_group_mode ())
error (_function_name () + " doesn\'t work in article mode!");
variable starting_group = current_newsgroup ();
call ("unsubscribe");
if (current_newsgroup () == starting_group) call ("bob");
}
%}}}
define looptastic_next_high_score () %{{{
{
if (is_group_mode ())
error (_function_name () + " doesn\'t work in group mode!");
ERROR_BLOCK % no high scores below cursor
{
variable
starting_article = extract_article_header ("Message-ID"),
starting_thread_was_collapsed = is_thread_collapsed ();
call ("header_bob");
if (get_header_flags () & HEADER_HIGH_SCORE)
{
if (extract_article_header ("Message-ID") != starting_article)
{
if (is_article_visible () == 1) call ("scroll_dn");
_clear_error ();
}
return ();
}
ERROR_BLOCK
{
set_input_string (starting_article);
call ("locate_header_by_msgid");
if (starting_thread_was_collapsed) collapse_thread ();
!if (looptastic_strict_compatibility)
{
_clear_error ();
error ("No high scoring articles.");
}
return ();
}
call ("next_high_score");
if (extract_article_header ("Message-ID") != starting_article)
_clear_error ();
}
call ("next_high_score");
}
%}}}
define header_prev_unread () % should be file-local %{{{
{
variable
t_size = 0,
starting_article = extract_article_header ("Message-ID"),
starting_thread_was_collapsed = is_thread_collapsed ();
while (header_up (1))
{
if (is_thread_collapsed ())
{
t_size = thread_size ();
uncollapse_thread ();
() = header_down (t_size - 1); % move to end of thread
loop (t_size - 1) % skip read headers
{
!if (get_header_flags () & HEADER_READ) return (1);
() = header_up (1);
}
collapse_thread ();
}
!if (get_header_flags () & HEADER_READ) return (1);
}
set_input_string (starting_article);
call ("locate_header_by_msgid");
if (starting_thread_was_collapsed) collapse_thread ();
message ("No previous unread articles.");
return (0);
}
%}}}
define looptastic_prev () %{{{
{
if (is_group_mode ())
error (_function_name () + " doesn\'t work in group mode.");
variable
starting_article = extract_article_header ("Message-ID"),
starting_thread_was_collapsed = is_thread_collapsed ();
call ("prev");
if (extract_article_header ("Message-ID") != starting_article) return ();
call ("header_eob"); % nothing unread above cursor
USER_BLOCK0
{
set_input_string (starting_article);
call ("locate_header_by_msgid");
if (starting_thread_was_collapsed) collapse_thread ();
message ("No previous unread articles");
}
if (extract_article_header ("Message-ID") == starting_article)
{
if (looptastic_strict_compatibility) % only one header in list
X_USER_BLOCK0 ();
else looptastic_skip_to_prev_group ();
return ();
}
if (is_thread_collapsed ()) % search from bottom of list
{
variable t_size = thread_size ();
uncollapse_thread ();
call ("header_eob");
loop (t_size - 1)
{
if (get_header_flags () & HEADER_READ) () = header_up (1);
else
{
if (is_article_visible ()) call ("scroll_dn");
return ();
}
}
collapse_thread ();
}
if (get_header_flags () & HEADER_READ)
{
variable message_ID = extract_article_header ("Message-ID");
call ("prev");
switch (extract_article_header ("Message-ID"))
{ orelse { case (message_ID) } { case (starting_article) } :
if (looptastic_strict_compatibility) % call("prev") failed
X_USER_BLOCK0 ();
else looptastic_skip_to_prev_group ();
}
return (); % call("prev") worked
}
if (is_article_visible ()) call ("scroll_dn");
}
%}}}
define looptastic_delete () %{{{
{
if (is_group_mode ())
error (_function_name () + " doesn\'t work in group mode.");
variable
starting_article = extract_article_header ("Message-ID"),
starting_thread_was_collapsed = is_thread_collapsed ();
call ("delete");
if (extract_article_header ("Message-ID") == starting_article)
{
call ("header_bob"); % no unread articles below
if (andelse
{ get_header_flags () & HEADER_READ }
{ header_next_unread () == 0 })
{
set_input_string (starting_article); % no unread articles above
call ("locate_header_by_msgid");
if (starting_thread_was_collapsed ()) collapse_thread ();
message ("No unread articles.");
}
}
}
%}}}
define looptastic_undelete () %{{{
{
if (is_group_mode ())
error (_function_name () + " doesn\'t work in group mode.");
variable starting_article = extract_article_header ("Message-ID");
call ("undelete");
if (extract_article_header ("Message-ID") == starting_article)
call ("header_bob");
}
%}}}
define looptastic_up () %{{{
{
if (is_group_mode ()) { !if (group_up_n (1)) call ("eob"); }
else !if (header_up (1)) call ("header_eob");
}
%}}}
define looptastic_down () %{{{
{
if (is_group_mode ()) { !if (group_down_n (1)) call ("bob"); }
else !if (header_down (1)) call ("header_bob");
}
%}}}
define looptastic_toggle_header_tag () %{{{
{
if (get_prefix_arg () != -1)
{
call ("toggle_header_tag");
return ();
}
variable message_ID = extract_article_header ("Message-ID");
call ("toggle_header_tag");
if (extract_article_header ("Message-ID") == message_ID)
call ("header_bob");
}
%}}}
define looptastic_tag_header () %{{{
{
variable
was_tagged = get_header_tag_number (),
message_ID = extract_article_header ("Message-ID");
call ("tag_header");
if (andelse
{ extract_article_header ("Message-ID") == message_ID }
{ was_tagged == 0 })
call ("header_bob");
}
%}}}
define prev_high_score () %{{{
{
if (is_group_mode ())
error (_function_name () + " doesn\'t work in group mode!");
variable
starting_article = extract_article_header ("Message-ID"),
starting_thread_was_collapsed = is_thread_collapsed (),
thread_head_article = "";
USER_BLOCK0
{
if (get_header_flags () & HEADER_HIGH_SCORE)
{
if (is_article_visible ()) call ("scroll_dn");
return ();
}
}
USER_BLOCK1
{
set_input_string (starting_article);
call ("locate_header_by_msgid");
if (starting_thread_was_collapsed) collapse_thread ();
error ("No more high scoring articles.");
}
% move cursor to the head of the thread
collapse_thread ();
uncollapse_thread ();
thread_head_article = extract_article_header ("Message-ID");
if (thread_head_article != starting_article)
{
set_input_string (starting_article);
call ("locate_header_by_msgid");
() = header_up (1);
while (extract_article_header ("Message-ID") != thread_head_article)
{
X_USER_BLOCK0 ();
() = header_up (1);
}
X_USER_BLOCK0 ();
}
if (starting_thread_was_collapsed) collapse_thread ();
!if (header_up (1)) X_USER_BLOCK1 ();
variable
thread_was_collapsed = 0,
t_size = 0,
index = 0;
do
{
thread_was_collapsed = is_thread_collapsed ();
!if (thread_was_collapsed) collapse_thread ();
t_size = thread_size ();
uncollapse_thread ();
() = header_down (t_size - 1);
for (index = t_size; index; index--)
{
X_USER_BLOCK0 ();
if (index != 1) () = header_up (1);
}
if (thread_was_collapsed) collapse_thread ();
}
while (header_up (1));
X_USER_BLOCK1 ();
}
%}}}
define looptastic_prev_high_score () %{{{
{
if (is_group_mode ())
error (_function_name + " doesn\'t work in group mode!");
ERROR_BLOCK
{
variable
sp = extract_article_header ("Message-ID"),
sp_thread_was_collapsed = is_thread_collapsed (),
eob_article = "",
eob_thread_was_collapsed = 0,
index = 0;
% Skip to last thread, check for high articles in last thread here.
call ("header_eob");
eob_article = extract_article_header ("Message-ID");
eob_thread_was_collapsed = is_thread_collapsed ();
!if (eob_thread_was_collapsed) collapse_thread ();
index = thread_size ();
uncollapse_thread ();
call ("header_eob");
for (; index; index--)
{
if (get_header_flags () & HEADER_HIGH_SCORE)
{
if (is_article_visible () == 1) call ("scroll_dn");
_clear_error ();
return ();
}
else if (index > 1) () = header_up (1);
}
if (eob_thread_was_collapsed) collapse_thread ();
% No high articles in last thread, so use prev_high_score() to check
% for high articles above last thread (not including head of last
% thread).
ERROR_BLOCK
{
set_input_string (sp);
call ("locate_header_by_msgid");
if (sp_thread_was_collapsed) collapse_thread ();
!if (looptastic_strict_compatibility)
{
_clear_error ();
error ("No high scoring articles.");
}
return ();
}
prev_high_score ();
% Don't want to loop and hit the same high scoring article every time
if (extract_article_header ("Message-ID") != sp)
{
_clear_error ();
return ();
}
}
prev_high_score ();
}
%}}}
Re: [slrn] Looptastic -- looping macros for slrn
Author: Christopher Masto
Date: Wed, 16 Sep 1998 00:00
Date: Wed, 16 Sep 1998 00:00
18 lines
1507 bytes
1507 bytes
In article <slrn-makes-me-omit-the-messageid>, Dawn Owens-Nicholson wrote: >Have you ever wanted some keys to loop around the group or article displays? >Now you can with this macro set. > >% Looping around slrn's group/article lists % -*- mode: slang; mode: fold -*- If I might make a documentation suggestion... even after taking a peek at the source, I'm still not sure what "loop around" means. Starts back at the top when you go past the bottom? Perhaps you could describe their function more explicitly in the next revision. -- Christopher Masto <chris+usenet@netmonger.net> Director of Operations, NetMonger Communications, Inc. "Behold the Power of Cheese"
Re: [slrn] Looptastic -- looping macros for slrn
Author: Dawn Owens-Nicholson
Date: Wed, 16 Sep 1998 00:00
Date: Wed, 16 Sep 1998 00:00
32 lines
2197 bytes
2197 bytes
Christopher Masto <chris+usenet@netmonger.net> wrote:
> In article <slrn-makes-me-omit-the-messageid>, Dawn Owens-Nicholson wrote:
How does slrn make you omit the message-ID (not that I think it's mandatory
to cite it here)?
> If I might make a documentation suggestion... even after taking a peek
> at the source, I'm still not sure what "loop around" means. Starts
> back at the top when you go past the bottom?
Yes, that's what it means. Usually when you go to the next or previous
article, you either go to the next unread newsgroup (next) or stop at the
top of the header list. This macro set makes the cursor go around the
header list in a loop so you only go to another newsgroup when you've marked
all the articles as read in the current group. This macro set wraps some
functions one is likely to use from the keyboard (call("prev"),
call("next"), call("skip_to_next_group"), call("skip_to_prev_group",
call("delete"), call("undelete"), call("toggle_header_tag"),
call("tag_header"), call("scroll_dn"), call("next_high_score"),
call("subscribe") and call("unsubscribe")).
You can skip to the next or previous group, and the group mode cursor loops
in a similar fashion--when you hit the top of the group list, the cursor
jumps to the bottom and when the cursor hits the bottom of the group list it
jumps to the top.
> Perhaps you could describe their function more explicitly in the next
> revision.
Okay, I'll see about clearing that up.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads