Article View: news.software.nntp
Article #39318Re: slrn - aplphabetic sorting
From: Dawn Owens-Nicholson
Date: Sat, 21 Aug 1999 00:00
Date: Sat, 21 Aug 1999 00:00
148 lines
4975 bytes
4975 bytes
John Oliver wrote:
> My slrn sorts newsgroups Z to A. I can, of course, use sort on my
> .jnewsrc. But ass soon as there's a new newsgroup, it shows up at the top,
> rather than in correct alphabetical order. Is there a way to make it sort
> all groups, new or otherwise, from A to Z?
Sven Guckes replied:
> set sorting_method 9
That applies only to article sorting, not group sorting.
To do group sorting within slrn you need to either use a macro or manually
position the group where you want it to go (either by transposing groups or
moving the group to its destination). Here's a macro that will sort groups
from A to Z or reverse the current order of the groups. I'm working on a
fancier version to do multiple types of sorting and sort a subset of the
groups.
To install, save the code as "group_sort.sl" (your homedir is a good easy
place to put it) and include the following in your slrn.rc:
interpret "group_sort.sl"
setkey group Group_Sort->ascii_sort "^Ks"
setkey group Group_Sort->reverse "^Kr"
Then quit slrn (if you're running it) and restart slrn. Now Control-K then
"s" will sort the groups A-Z. Flipping the order of the groups (no matter
how they're arranged) can be done by hitting Control-K then "r". I made up
these keybindings to get you started, change them if you wish.
If you're into S-Lang macros, you might find Group_Sort->move_group_up_n()
and Group_Sort->move_group_down_n() handy. They work just like
group_up/down_n() but these functions move the current group n groups up or
down the group list (instead of moving the cursor n groups up or down the
group list). If you have no idea what this paragraph is referring to,
that's okay.
Happy newsreading!
% Sort newsgroup list % -*- mode: slang; mode: fold -*-
implements ("Group_Sort");
static define move_group_up_n (n) %{{{
{
!if (is_group_mode ())
error (_function_name () + " doesn\'t work in article mode");
variable
group = current_newsgroup (),
moved = 0;
loop (n)
{
call ("transpose_groups");
if (current_newsgroup () == group) break;
while (current_newsgroup () != group) () = group_search (group);
moved++;
}
return (moved);
}
%}}}
static define move_group_down_n (n) %{{{
{
!if (is_group_mode ())
error (_function_name () + " doesn\'t work in article mode");
variable
group = current_newsgroup (),
moved = 0;
loop (n)
{
!if (group_down_n (1)) break;
call ("transpose_groups");
moved++;
if (current_newsgroup () == group) break;
() = group_up_n (1);
}
return (moved);
}
%}}}
static define ascii_sort () %{{{
{
!if (is_group_mode ())
error (_function_name () + " doesn\'t work in article mode");
variable
sg = current_newsgroup (),
group_list = Assoc_Type[Null_Type],
num_groups = 0,
counter = 0,
group = NULL;
call ("bob");
do group_list[current_newsgroup ()] = NULL;
while (group_down_n (1));
group_list = assoc_get_keys (group_list);
group_list = group_list[array_sort (group_list, &strcmp)];
num_groups = length (group_list);
foreach (group_list)
{
group = ();
while (current_newsgroup () != group) () = group_search (group);
() = move_group_up_n (num_groups);
() = move_group_down_n (counter);
counter++;
}
while (current_newsgroup () != sg) () = group_search (sg);
}
%}}}
static define reverse () %{{{
{
!if (is_group_mode ())
error (_function_name () + " doesn\'t work in article mode");
variable
sg = current_newsgroup (),
bignumber = 1000,
num_groups = 0,
i = 0;
call ("bob");
do
{
i = move_group_down_n (bignumber);
num_groups += i;
}
while (i == bignumber);
for (i = 1; i <= num_groups; i++)
{
call ("bob");
() = move_group_down_n (num_groups - i);
}
while (current_newsgroup != sg) () = group_search (sg);
}
%}}}
Technical Details
Message-ID:
<slrn7rtqfd.b43.bluemoon@ux6.cso.uiuc.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<37bc0eb7.258418358@news.escnd1.sdca.home.com> <7pjj7i$gj$5@fu-berlin.de>Show Full Headers
Complete Article Headers
Message-ID: <slrn7rtqfd.b43.bluemoon@ux6.cso.uiuc.edu> Subject: Re: slrn - aplphabetic sorting Date: Sat, 21 Aug 1999 00:00:00 +0000 From: bluemoon@ux6.cso.uiuc.edu (Dawn Owens-Nicholson) References: <37bc0eb7.258418358@news.escnd1.sdca.home.com> <7pjj7i$gj$5@fu-berlin.de> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 515555421 Organization: University of Illinois at Urbana-Champaign Followup-To: news.software.readers User-Agent: slrn/0.9.5.7 (UNIX) Newsgroups: news.software.nntp,news.software.readers