From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/26002 Path: main.gmane.org!not-for-mail From: Shenghuo ZHU Newsgroups: gmane.emacs.gnus.general Subject: Re: Topic sorting Date: 22 Oct 1999 11:13:54 -0400 Organization: U of Rochester Sender: owner-ding@hpc.uh.edu Message-ID: <5baepbbf7x.fsf@giga.cs.rochester.edu> References: <7t1r9iosjlk.fsf@fly.srk.fer.hr> <87so34il9l.fsf@pc-hrvoje.srce.hr> <7t1so33scpl.fsf@fly.srk.fer.hr> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1035163293 17162 80.91.224.250 (21 Oct 2002 01:21:33 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 01:21:33 +0000 (UTC) Return-Path: Original-Received: from bart.math.uh.edu (bart.math.uh.edu [129.7.128.48]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id LAA19257 for ; Fri, 22 Oct 1999 11:14:29 -0400 (EDT) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by bart.math.uh.edu (8.9.1/8.9.1) with ESMTP id KAB14330; Fri, 22 Oct 1999 10:14:26 -0500 (CDT) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Fri, 22 Oct 1999 10:14:46 -0500 (CDT) Original-Received: from sclp3.sclp.com (root@sclp3.sclp.com [204.252.123.139]) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id KAA14786 for ; Fri, 22 Oct 1999 10:14:33 -0500 (CDT) Original-Received: from cayuga.cs.rochester.edu (cayuga.cs.rochester.edu [192.5.53.209]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id LAA19249 for ; Fri, 22 Oct 1999 11:13:57 -0400 (EDT) Original-Received: from giga.cs.rochester.edu (giga.cs.rochester.edu [192.5.53.186]) by cayuga.cs.rochester.edu (8.9.3/Q) with ESMTP id LAA20747 for ; Fri, 22 Oct 1999 11:13:55 -0400 (EDT) Original-Received: (from zsh@localhost) by giga.cs.rochester.edu (8.9.1b+Sun/Q++) id LAA28452; Fri, 22 Oct 1999 11:13:55 -0400 (EDT) Original-To: ding@gnus.org X-Attribution: ZSH X-Face: 'IF:e51ib'Qbl^(}l^&4-J`'P!@[4~O|&k#:@Gld#b/]oMq&`&FVY._3+b`mzp~Jeve~/#/ ERD!OTe<86UhyN=l`mrPY)M7_}`Ktt\K+58Z!hu7>qU,i.N7TotU[FYE(f1;}`g2xj!u*l`^&=Q!g{ *q|ddto|nkt"$r,K$[)"|6,elPH= GJ6Q In-Reply-To: Toni Drabik's message of "22 Oct 1999 16:16:06 +0200" Original-Lines: 28 User-Agent: Gnus/5.07009701 (Pterodactyl Gnus v0.97.1) Emacs/20.4 Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:26002 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:26002 --=-=-= >>>>> "Toni" == Toni Drabik writes: [...] >> I just wrote the function. I'll put it into CVS if people like it. Toni> Yes, please. [...] CVS'd (Topics Topics Sort). Another function, gnus-move-topic, will move topic itself by pressing `T m' on a topic button while no groups are marked. -- Shenghuo ZHU 1999-10-22 11:03:00 Shenghuo ZHU * gnus-topic.el (gnus-topic-sort-topics-1): New function. (gnus-topic-sort-topics): New function. (gnus-topic-make-menu-bar): Add sort-topics. (gnus-topic-move): New function. (gnus-topic-move-group): Move the topic if no group selected. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=97-113.diff Index: gnus-topic.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus-topic.el,v retrieving revision 5.8 diff -u -r5.8 gnus-topic.el --- gnus-topic.el 1999/09/27 21:32:59 5.8 +++ gnus-topic.el 1999/10/22 15:08:22 @@ -982,6 +982,7 @@ ["Create" gnus-topic-create-topic t] ["Mark" gnus-topic-mark-topic t] ["Indent" gnus-topic-indent t] + ["Sort" gnus-topic-sort-topics t] ["Toggle hide empty" gnus-topic-toggle-display-empty-topics t] ["Edit parameters" gnus-topic-edit-parameters t]) ["List active" gnus-topic-list-active t])))) @@ -1120,23 +1121,25 @@ (completing-read "Move to topic: " gnus-topic-alist nil t))) (let ((groups (gnus-group-process-prefix n)) (topicl (assoc topic gnus-topic-alist)) - (start-group (progn (forward-line 1) (gnus-group-group-name))) (start-topic (gnus-group-topic-name)) + (start-group (progn (forward-line 1) (gnus-group-group-name))) entry) - (mapcar - (lambda (g) - (gnus-group-remove-mark g) - (when (and - (setq entry (assoc (gnus-current-topic) gnus-topic-alist)) - (not copyp)) - (setcdr entry (gnus-delete-first g (cdr entry)))) - (nconc topicl (list g))) - groups) - (gnus-topic-enter-dribble) - (if start-group - (gnus-group-goto-group start-group) - (gnus-topic-goto-topic start-topic)) - (gnus-group-list-groups))) + (if (and (not groups) (not copyp) start-topic) + (gnus-topic-move start-topic topic) + (mapcar + (lambda (g) + (gnus-group-remove-mark g) + (when (and + (setq entry (assoc (gnus-current-topic) gnus-topic-alist)) + (not copyp)) + (setcdr entry (gnus-delete-first g (cdr entry)))) + (nconc topicl (list g))) + groups) + (gnus-topic-enter-dribble) + (if start-group + (gnus-group-goto-group start-group) + (gnus-topic-goto-topic start-topic)) + (gnus-group-list-groups)))) (defun gnus-topic-remove-group (&optional arg) "Remove the current group from the topic." @@ -1475,6 +1478,55 @@ If REVERSE, sort in reverse order." (interactive "P") (gnus-topic-sort-groups 'gnus-group-sort-by-method reverse)) + +(defun gnus-topic-sort-topics-1 (top reverse) + (if (cdr top) + (let ((subtop + (mapcar `(lambda (top) + (gnus-topic-sort-topics-1 top ,reverse)) + (sort (cdr top) + '(lambda (t1 t2) + (string-lessp (caar t1) (caar t2))))))) + (setcdr top (if reverse (reverse subtop) subtop)))) + top) + +(defun gnus-topic-sort-topics (&optional topic reverse) + "Sort topics in TOPIC alphabeticaly by topic name. +If REVERSE, reverse the sorting order." + (interactive + (list (completing-read "Sort topics in : " gnus-topic-alist nil t + (gnus-current-topic)) + current-prefix-arg)) + (let ((topic-topology (or (and topic (cdr (gnus-topic-find-topology topic))) + gnus-topic-topology))) + (gnus-topic-sort-topics-1 topic-topology reverse) + (gnus-topic-enter-dribble) + (gnus-group-list-groups) + (gnus-topic-goto-topic topic))) + +(defun gnus-topic-move (current to) + "Move the CURRENT topic to TO." + (interactive + (list + (gnus-group-topic-name) + (completing-read "Move to topic: " gnus-topic-alist nil t))) + (unless (and current to) + (error "Can't find topic")) + (let ((current-top (cdr (gnus-topic-find-topology current))) + (to-top (cdr (gnus-topic-find-topology to)))) + (unless current-top + (error "Can't find topic `%s'" current)) + (unless to-top + (error "Can't find topic `%s'" to)) + (if (gnus-topic-find-topology to current-top 0) ;; Don't care the level + (error "Can't move `%s' to its sub-level" current)) + (gnus-topic-find-topology current nil nil 'delete) + (while (cdr to-top) + (setq to-top (cdr to-top))) + (setcdr to-top (list current-top)) + (gnus-topic-enter-dribble) + (gnus-group-list-groups) + (gnus-topic-goto-topic current))) (provide 'gnus-topic) --=-=-=--