🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #235522

Re: Sort newsgroups in slrn?

#235522
From: John E. Davis
Date: Thu, 17 Sep 2009 14:57
91 lines
3725 bytes
On Thu, 17 Sep 2009 20:34:14 +1000, andrew <andrew@skamandros.invalid>
wrote:
> I cannot tell a lie, I was not actually aware that groups could be moved
> with the 'm' key :-). For the 14 groups I subscribe to this will be more
> than sufficient but perhaps more functionality will be added when the
> development train leaves the station again?

It is unclear to me that additional functionality is required.  For
example, I threw this together in about 20 minutes.   The public
function, "group_sort", could be called from a startup hook.  The
example below binds it to a key.  --John

#v+
private define sort_groups_alphabetically ()
{
   variable groups = get_group_order ();
   groups = groups [array_sort(groups)];
   set_group_order (groups);
}

private variable Big8_Groups = 
  ["alt", "comp", "misc", "news", "rec", "sci", "soc", "talk"];

private define slice_groups (hierarchies)
{
   variable
     num_hierarchies = length(hierarchies),
     groups = get_group_order (),
     new_groups = String_Type[length(groups)],
     hierarchy_groups = Array_Type[num_hierarchies+1];
   
   groups = groups[array_sort(groups)];
   variable i, j, k;
   hierarchies = hierarchies + ".";
   _for i (0, num_hierarchies-1, 1)
     {
	variable 
	  hierarchy = hierarchies[i],
	  cmp = array_map (Int_Type, &strncmp, hierarchy, 
			   groups, strlen(hierarchy));

	j = where (cmp, &k);
	hierarchy_groups[i] = groups[k];
	groups = groups[j];
     }
   hierarchy_groups[-1] = groups;
   return hierarchy_groups;
}

private define sort_groups_big8_first ()
{
   variable 
     hierarchy_groups = slice_groups (Big8_Groups),
     groups = String_Type[0], i;
   
   _for i (0, length(hierarchy_groups)-1, 1)
     groups = [groups, hierarchy_groups[i]];
   
   set_group_order (groups);
}

private define sort_groups_big8_last ()
{
   variable 
     hierarchy_groups = slice_groups (Big8_Groups),
     groups, i;

   groups = hierarchy_groups[-1];
   _for i (0, length(hierarchy_groups)-2, 1)
     groups = [groups, hierarchy_groups[i]];

   set_group_order (groups);
}

define group_sort ()
{
   if (0 == is_group_mode ())
     throw UsageError, "group_sort is available only in group mode";

   switch (get_select_box_response ("Sort Groups",
				    "Alphabetically",
				    "Big 8 first",
				    "Big 8 last",
				    3))
     { case 0: sort_groups_alphabetically (); }
     { case 1: sort_groups_big8_first (); }
     { case 2: sort_groups_big8_last (); }
}

definekey ("group_sort", "\es", "group");
#v-
Technical Details
Message-ID: <slrnhb4jiq.22n.jed@aluche.mit.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!micro-heart-of-gold.mit.edu!not-for-mail
References: <h8s9mg$cp6$2@news.albasani.net> <20090917142953.939@skamandros.andrews-corner.org> <slrnhb3qi4.4kr.invalid@invalid.org> <20090917203157.363@skamandros.andrews-corner.org>

Show Full Headers
Complete Article Headers
Message-ID: <slrnhb4jiq.22n.jed@aluche.mit.edu>
Subject: Re: Sort newsgroups in slrn?
Date: Thu, 17 Sep 2009 14:57:03 +0000
From: "John E. Davis" <jed@jedsoft.org>
References: <h8s9mg$cp6$2@news.albasani.net> <20090917142953.939@skamandros.andrews-corner.org> <slrnhb3qi4.4kr.invalid@invalid.org> <20090917203157.363@skamandros.andrews-corner.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!micro-heart-of-gold.mit.edu!not-for-mail
Newsgroups: news.software.readers
Organization: MIT EECS ECF
Lines: 91
Reply-To: davis@space.mit.edu
NNTP-Posting-Host: aluche.mit.edu
X-Trace: micro-heart-of-gold.mit.edu 1253199423 63646 18.75.2.45 (17 Sep 2009
X-Complaints-To: usenet@micro-heart-of-gold.mit.edu
NNTP-Posting-Date: Thu, 17 Sep 2009 14:57:03 +0000 (UTC)
User-Agent: slrn/pre1.0.0-12 (Linux)