From: Shenghuo ZHU <zsh@cs.rochester.edu>
Subject: Re: Topic sorting
Date: 22 Oct 1999 11:13:54 -0400 [thread overview]
Message-ID: <5baepbbf7x.fsf@giga.cs.rochester.edu> (raw)
In-Reply-To: Toni Drabik's message of "22 Oct 1999 16:16:06 +0200"
[-- Attachment #1: Type: text/plain, Size: 641 bytes --]
>>>>> "Toni" == Toni Drabik <tdrabik@public.srce.hr> 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 <zsh@cs.rochester.edu>
* 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 97-113.diff --]
[-- Type: text/x-patch, Size: 3967 bytes --]
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)
next prev parent reply other threads:[~1999-10-22 15:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-21 17:35 Toni Drabik
1999-10-21 18:40 ` Robin S. Socha
1999-10-21 19:09 ` Hrvoje Niksic
1999-10-21 20:34 ` Robin S. Socha
1999-10-22 14:16 ` Toni Drabik
1999-10-22 15:13 ` Shenghuo ZHU [this message]
1999-10-21 20:07 ` Justin Sheehy
1999-10-21 20:41 ` Shenghuo ZHU
1999-10-22 6:33 ` Norbert Koch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5baepbbf7x.fsf@giga.cs.rochester.edu \
--to=zsh@cs.rochester.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).