1 ;;; gnus-topic.el --- a folding minor mode for Gnus group buffers
2 ;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc.
4 ;; Author: Ilja Weis <kult@uni-paderborn.de>
5 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
36 (defgroup gnus-topic nil
40 (defvar gnus-topic-mode nil
41 "Minor mode for Gnus group buffers.")
43 (defcustom gnus-topic-mode-hook nil
44 "Hook run in topic mode buffers."
48 (defcustom gnus-topic-line-format "%i[ %(%{%n%}%) -- %A ]%v\n"
49 "Format of topic lines.
50 It works along the same lines as a normal formatting string,
51 with some simple extensions.
53 %i Indentation based on topic level.
55 %v Nothing if the topic is visible, \"...\" otherwise.
56 %g Number of groups in the topic.
57 %a Number of unread articles in the groups in the topic.
58 %A Number of unread articles in the groups in the topic and its subtopics.
63 (defcustom gnus-topic-indent-level 2
64 "*How much each subtopic should be indented."
68 (defcustom gnus-topic-display-empty-topics t
69 "*If non-nil, display the topic lines even of topics that have no unread articles."
73 ;; Internal variables.
75 (defvar gnus-topic-active-topology nil)
76 (defvar gnus-topic-active-alist nil)
77 (defvar gnus-topic-unreads nil)
79 (defvar gnus-topology-checked-p nil
80 "Whether the topology has been checked in this session.")
82 (defvar gnus-topic-killed-topics nil)
83 (defvar gnus-topic-inhibit-change-level nil)
85 (defconst gnus-topic-line-format-alist
89 (?g number-of-groups ?d)
90 (?a (gnus-topic-articles-in-topic entries) ?d)
91 (?A total-number-of-articles ?d)
94 (defvar gnus-topic-line-format-spec nil)
98 (defun gnus-group-topic-name ()
99 "The name of the topic on the current line."
100 (let ((topic (get-text-property (gnus-point-at-bol) 'gnus-topic)))
101 (and topic (symbol-name topic))))
103 (defun gnus-group-topic-level ()
104 "The level of the topic on the current line."
105 (get-text-property (gnus-point-at-bol) 'gnus-topic-level))
107 (defun gnus-group-topic-unread ()
108 "The number of unread articles in topic on the current line."
109 (get-text-property (gnus-point-at-bol) 'gnus-topic-unread))
111 (defun gnus-topic-unread (topic)
112 "Return the number of unread articles in TOPIC."
113 (or (cdr (assoc topic gnus-topic-unreads))
116 (defun gnus-group-topic-p ()
117 "Return non-nil if the current line is a topic."
118 (gnus-group-topic-name))
120 (defun gnus-topic-visible-p ()
121 "Return non-nil if the current topic is visible."
122 (get-text-property (gnus-point-at-bol) 'gnus-topic-visible))
124 (defun gnus-topic-articles-in-topic (entries)
128 (when (numberp (setq number (car (pop entries))))
129 (incf total number)))
132 (defun gnus-group-topic (group)
133 "Return the topic GROUP is a member of."
134 (let ((alist gnus-topic-alist)
137 (when (member group (cdar alist))
138 (setq out (caar alist)
140 (setq alist (cdr alist)))
143 (defun gnus-group-parent-topic (group)
144 "Return the topic GROUP is member of by looking at the group buffer."
146 (set-buffer gnus-group-buffer)
147 (if (gnus-group-goto-group group)
149 (gnus-group-topic group))))
151 (defun gnus-topic-goto-topic (topic)
154 (gnus-goto-char (text-property-any (point-min) (point-max)
155 'gnus-topic (intern topic)))))
157 (defun gnus-current-topic ()
158 "Return the name of the current topic."
160 (or (get-text-property (point) 'gnus-topic)
162 (and (gnus-goto-char (previous-single-property-change
163 (point) 'gnus-topic))
164 (get-text-property (max (1- (point)) (point-min))
167 (symbol-name result))))
169 (defun gnus-current-topics (&optional topic)
170 "Return a list of all current topics, lowest in hierarchy first.
171 If TOPIC, start with that topic."
172 (let ((topic (or topic (gnus-current-topic)))
176 (setq topic (gnus-topic-parent-topic topic)))
179 (defun gnus-group-active-topic-p ()
180 "Say whether the current topic comes from the active topics."
183 (get-text-property (point) 'gnus-active)))
185 (defun gnus-topic-find-groups (topic &optional level all lowest)
186 "Return entries for all visible groups in TOPIC."
187 (let ((groups (cdr (assoc topic gnus-topic-alist)))
188 info clevel unread group params visible-groups entry active)
189 (setq lowest (or lowest 1))
190 (setq level (or level gnus-level-unsubscribed))
191 ;; We go through the newsrc to look for matches.
193 (when (setq group (pop groups))
194 (setq entry (gnus-gethash group gnus-newsrc-hashtb)
196 params (gnus-info-params info)
197 active (gnus-active group)
198 unread (or (car entry)
199 (and (not (equal group "dummy.group"))
201 (- (1+ (cdr active)) (car active))))
202 clevel (or (gnus-info-level info)
203 (if (member group gnus-zombie-list)
204 gnus-level-zombie gnus-level-killed))))
206 unread ; nil means that the group is dead.
208 (>= clevel lowest) ; Is inside the level we want.
211 gnus-group-list-inactive-groups
213 (and gnus-list-groups-with-ticked-articles
214 (cdr (assq 'tick (gnus-info-marks info))))
215 ; Has right readedness.
216 ;; Check for permanent visibility.
217 (and gnus-permanently-visible-groups
218 (string-match gnus-permanently-visible-groups group))
219 (memq 'visible params)
220 (cdr (assq 'visible params)))
221 ;; Add this group to the list of visible groups.
222 (push (or entry group) visible-groups)))
223 (nreverse visible-groups)))
225 (defun gnus-topic-previous-topic (topic)
226 "Return the previous topic on the same level as TOPIC."
227 (let ((top (cddr (gnus-topic-find-topology
228 (gnus-topic-parent-topic topic)))))
229 (unless (equal topic (caaar top))
230 (while (and top (not (equal (caaadr top) topic)))
231 (setq top (cdr top)))
234 (defun gnus-topic-parent-topic (topic &optional topology)
235 "Return the parent of TOPIC."
237 (setq topology gnus-topic-topology))
238 (let ((parent (car (pop topology)))
241 (not (setq found (equal (caaar topology) topic)))
242 (not (setq result (gnus-topic-parent-topic
243 topic (car topology)))))
244 (setq topology (cdr topology)))
245 (or result (and found parent))))
247 (defun gnus-topic-next-topic (topic &optional previous)
248 "Return the next sibling of TOPIC."
249 (let ((parentt (cddr (gnus-topic-find-topology
250 (gnus-topic-parent-topic topic))))
253 (not (equal (caaar parentt) topic)))
254 (setq prev (caaar parentt)
255 parentt (cdr parentt)))
260 (defun gnus-topic-forward-topic (num)
261 "Go to the next topic on the same level as the current one."
262 (let* ((topic (gnus-current-topic))
263 (way (if (< num 0) 'gnus-topic-previous-topic
264 'gnus-topic-next-topic))
266 (while (and (not (zerop num))
267 (setq topic (funcall way topic)))
268 (when (gnus-topic-goto-topic topic)
271 (goto-char (point-max)))
274 (defun gnus-topic-find-topology (topic &optional topology level remove)
275 "Return the topology of TOPIC."
277 (setq topology gnus-topic-topology)
281 (if (equal (caar topology) topic)
284 (delq topology remove))
285 (cons level topology))
286 (setq topology (cdr topology))
288 (not (setq result (gnus-topic-find-topology
289 topic (car topology) (1+ level)
291 (setq topology (cdr topology)))
294 (defvar gnus-tmp-topics nil)
295 (defun gnus-topic-list (&optional topology)
296 "Return a list of all topics in the topology."
298 (setq topology gnus-topic-topology
299 gnus-tmp-topics nil))
300 (push (caar topology) gnus-tmp-topics)
301 (mapcar 'gnus-topic-list (cdr topology))
304 ;;; Topic parameter jazz
306 (defun gnus-topic-parameters (topic)
307 "Return the parameters for TOPIC."
308 (let ((top (gnus-topic-find-topology topic)))
310 (nth 3 (cadr top)))))
312 (defun gnus-topic-set-parameters (topic parameters)
313 "Set the topic parameters of TOPIC to PARAMETERS."
314 (let ((top (gnus-topic-find-topology topic)))
316 (error "No such topic: %s" topic))
317 ;; We may have to extend if there is no parameters here
319 (unless (nthcdr 2 (cadr top))
320 (nconc (cadr top) (list nil)))
321 (unless (nthcdr 3 (cadr top))
322 (nconc (cadr top) (list nil)))
323 (setcar (nthcdr 3 (cadr top)) parameters)
325 (format "(gnus-topic-set-parameters %S '%S)" topic parameters))))
327 (defun gnus-group-topic-parameters (group)
328 "Compute the group parameters for GROUP taking into account inheritance from topics."
329 (let ((params-list (copy-sequence (gnus-group-get-parameter group))))
331 (gnus-group-goto-group group)
333 (gnus-topic-hierarchical-parameters (gnus-current-topic))))))
335 (defun gnus-topic-hierarchical-parameters (topic)
336 "Return a topic list computed for TOPIC."
337 (let ((topics (gnus-current-topics topic))
338 params-list param out params)
340 (push (gnus-topic-parameters (pop topics)) params-list))
341 ;; We probably have lots of nil elements here, so
342 ;; we remove them. Probably faster than doing this "properly".
343 (setq params-list (delq nil params-list))
344 ;; Now we have all the parameters, so we go through them
345 ;; and do inheritance in the obvious way.
346 (while (setq params (pop params-list))
347 (while (setq param (pop params))
349 (setq param (cons param t)))
350 ;; Override any old versions of this param.
351 (gnus-pull (car param) out)
353 ;; Return the resulting parameter list.
356 ;;; General utility functions
358 (defun gnus-topic-enter-dribble ()
360 (format "(setq gnus-topic-topology '%S)" gnus-topic-topology)))
362 ;;; Generating group buffers
364 (defun gnus-group-prepare-topics (level &optional all lowest regexp list-topic topic-level)
365 "List all newsgroups with unread articles of level LEVEL or lower.
366 Use the `gnus-group-topics' to sort the groups.
367 If ALL is non-nil, list groups that have no unread articles.
368 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher."
369 (set-buffer gnus-group-buffer)
370 (let ((buffer-read-only nil)
371 (lowest (or lowest 1)))
373 (when (or (not gnus-topic-alist)
374 (not gnus-topology-checked-p))
375 (gnus-topic-check-topology))
381 (when (and (>= level gnus-level-zombie)
382 (<= lowest gnus-level-zombie))
383 (gnus-group-prepare-flat-list-dead
384 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
388 (when (and (>= level gnus-level-killed) (<= lowest gnus-level-killed))
389 (gnus-group-prepare-flat-list-dead
390 (setq gnus-killed-list (sort gnus-killed-list 'string<))
396 (when (< lowest gnus-level-zombie)
398 (let ((top (gnus-topic-find-topology list-topic)))
399 (gnus-topic-prepare-topic (cdr top) (car top)
400 (or topic-level level) all
402 (gnus-topic-prepare-topic gnus-topic-topology 0
403 (or topic-level level) all
406 (gnus-group-set-mode-line)
407 (setq gnus-group-list-mode (cons level all))
408 (gnus-run-hooks 'gnus-group-prepare-hook))))
410 (defun gnus-topic-prepare-topic (topicl level &optional list-level all silent
412 "Insert TOPIC into the group buffer.
413 If SILENT, don't insert anything. Return the number of unread
414 articles in the topic and its subtopics."
415 (let* ((type (pop topicl))
416 (entries (gnus-topic-find-groups
417 (car type) list-level
420 (gnus-topic-hierarchical-parameters
423 (visiblep (and (eq (nth 1 type) 'visible) (not silent)))
424 (gnus-group-indentation
425 (make-string (* gnus-topic-indent-level level) ? ))
426 (beg (progn (beginning-of-line) (point)))
427 (topicl (reverse topicl))
428 (all-entries entries)
429 (point-max (point-max))
432 info entry end active tick)
433 ;; Insert any sub-topics.
436 (gnus-topic-prepare-topic
437 (pop topicl) (1+ level) list-level all
438 (not visiblep) lowest)))
441 ;; Insert all the groups that belong in this topic.
442 (while (setq entry (pop entries))
446 (gnus-group-insert-group-line
447 entry (if (member entry gnus-zombie-list)
448 gnus-level-zombie gnus-level-killed)
449 nil (- (1+ (cdr (setq active (gnus-active entry))))
453 (when (setq info (nth 2 entry))
454 (gnus-group-insert-group-line
455 (gnus-info-group info)
456 (gnus-info-level info) (gnus-info-marks info)
457 (car entry) (gnus-info-method info)))))
458 (when (and (listp entry)
459 (numberp (car entry)))
460 (incf unread (car entry)))
464 ;; Insert the topic line.
465 (when (and (not silent)
466 (or gnus-topic-display-empty-topics ;We want empty topics
467 (not (zerop unread)) ;Non-empty
468 tick ;Ticked articles
469 (/= point-max (point-max)))) ;Unactivated groups
470 (gnus-extent-start-open (point))
471 (gnus-topic-insert-topic-line
473 (not (eq (nth 2 type) 'hidden))
474 level all-entries unread))
475 (gnus-topic-update-unreads (car type) unread)
479 (defun gnus-topic-remove-topic (&optional insert total-remove hide in-level)
480 "Remove the current topic."
481 (let ((topic (gnus-group-topic-name))
482 (level (gnus-group-topic-level))
483 (beg (progn (beginning-of-line) (point)))
486 (while (and (zerop (forward-line 1))
487 (> (or (gnus-group-topic-level) (1+ level)) level)))
488 (delete-region beg (point))
489 ;; Do the change in this rather odd manner because it has been
490 ;; reported that some topics share parts of some lists, for some
491 ;; reason. I have been unable to determine why this is the
492 ;; case, but this hack seems to take care of things.
493 (let ((data (cadr (gnus-topic-find-topology topic))))
495 (list (if insert 'visible 'invisible)
499 (setq gnus-topic-alist
500 (delq (assoc topic gnus-topic-alist) gnus-topic-alist))
501 (gnus-topic-insert-topic topic in-level)))))
503 (defun gnus-topic-insert-topic (topic &optional level)
505 (gnus-group-prepare-topics
506 (car gnus-group-list-mode) (cdr gnus-group-list-mode)
507 nil nil topic level))
509 (defun gnus-topic-fold (&optional insert)
510 "Remove/insert the current topic."
511 (let ((topic (gnus-group-topic-name)))
514 (if (not (gnus-group-active-topic-p))
515 (gnus-topic-remove-topic
516 (or insert (not (gnus-topic-visible-p))))
517 (let ((gnus-topic-topology gnus-topic-active-topology)
518 (gnus-topic-alist gnus-topic-active-alist)
519 (gnus-group-list-mode (cons 5 t)))
520 (gnus-topic-remove-topic
521 (or insert (not (gnus-topic-visible-p))) nil nil 9)
522 (gnus-topic-enter-dribble)))))))
524 (defun gnus-topic-insert-topic-line (name visiblep shownp level entries
526 (let* ((visible (if visiblep "" "..."))
527 (indentation (make-string (* gnus-topic-indent-level level) ? ))
528 (total-number-of-articles unread)
529 (number-of-groups (length entries))
530 (active-topic (eq gnus-topic-alist gnus-topic-active-alist))
532 (gnus-topic-update-unreads name unread)
535 (gnus-add-text-properties
538 (eval gnus-topic-line-format-spec))
539 (list 'gnus-topic (intern name)
540 'gnus-topic-level level
541 'gnus-topic-unread unread
542 'gnus-active active-topic
543 'gnus-topic-visible visiblep))))
545 (defun gnus-topic-update-unreads (topic unreads)
546 (setq gnus-topic-unreads (delq (assoc topic gnus-topic-unreads)
548 (push (cons topic unreads) gnus-topic-unreads))
550 (defun gnus-topic-update-topics-containing-group (group)
551 "Update all topics that have GROUP as a member."
552 (when (and (eq major-mode 'gnus-group-mode)
555 (let ((alist gnus-topic-alist))
556 ;; This is probably not entirely correct. If a topic
557 ;; isn't shown, then it's not updated. But the updating
558 ;; should be performed in any case, since the topic's
559 ;; parent should be updated. Pfft.
561 (when (and (member group (cdar alist))
562 (gnus-topic-goto-topic (caar alist)))
563 (gnus-topic-update-topic-line (caar alist)))
566 (defun gnus-topic-update-topic ()
567 "Update all parent topics to the current group."
568 (when (and (eq major-mode 'gnus-group-mode)
570 (let ((group (gnus-group-group-name))
572 (buffer-read-only nil))
574 (gnus-get-info group)
575 (gnus-topic-goto-topic (gnus-current-topic)))
576 (gnus-topic-update-topic-line (gnus-group-topic-name))
579 (gnus-group-position-point)))))
581 (defun gnus-topic-goto-missing-group (group)
582 "Place point where GROUP is supposed to be inserted."
583 (let* ((topic (gnus-group-topic group))
584 (groups (cdr (assoc topic gnus-topic-alist)))
585 (g (cdr (member group groups)))
587 ;; Try to jump to a visible group.
588 (while (and g (not (gnus-group-goto-group (car g) t)))
590 ;; It wasn't visible, so we try to see where to insert it.
592 (setq g (cdr (member group (reverse groups))))
593 (while (and g unfound)
594 (when (gnus-group-goto-group (pop g) t)
599 (not (gnus-topic-goto-missing-topic topic)))
600 (gnus-topic-insert-topic-line
601 topic t t (car (gnus-topic-find-topology topic)) nil 0)))))
603 (defun gnus-topic-goto-missing-topic (topic)
604 (if (gnus-topic-goto-topic topic)
606 ;; Topic not displayed.
607 (let* ((top (gnus-topic-find-topology
608 (gnus-topic-parent-topic topic)))
609 (tp (reverse (cddr top))))
610 (while (not (equal (caaar tp) topic))
614 (not (gnus-topic-goto-topic (caaar tp))))
617 (gnus-topic-forward-topic 1)
618 (gnus-topic-goto-missing-topic (caadr top))))
621 (defun gnus-topic-update-topic-line (topic-name &optional reads)
622 (let* ((top (gnus-topic-find-topology topic-name))
624 (children (cddr top))
625 (entries (gnus-topic-find-groups
626 (car type) (car gnus-group-list-mode)
627 (cdr gnus-group-list-mode)))
628 (parent (gnus-topic-parent-topic topic-name))
629 (all-entries entries)
631 old-unread entry new-unread)
632 (when (gnus-topic-goto-topic (car type))
633 ;; Tally all the groups that belong in this topic.
635 (setq unread (- (gnus-group-topic-unread) reads))
637 (incf unread (gnus-topic-unread (caar (pop children)))))
638 (while (setq entry (pop entries))
639 (when (numberp (car entry))
640 (incf unread (car entry)))))
641 (setq old-unread (gnus-group-topic-unread))
642 ;; Insert the topic line.
643 (gnus-topic-insert-topic-line
644 (car type) (gnus-topic-visible-p)
645 (not (eq (nth 2 type) 'hidden))
646 (gnus-group-topic-level) all-entries unread)
649 (setq new-unread (gnus-group-topic-unread)))
652 (gnus-topic-update-topic-line
654 (- (or old-unread 0) (or new-unread 0))))
657 (defun gnus-topic-group-indentation ()
659 (* gnus-topic-indent-level
662 (gnus-topic-goto-topic (gnus-current-topic))
663 (gnus-group-topic-level))
669 (gnus-add-shutdown 'gnus-topic-close 'gnus)
671 (defun gnus-topic-close ()
672 (setq gnus-topic-active-topology nil
673 gnus-topic-active-alist nil
674 gnus-topic-killed-topics nil
675 gnus-topology-checked-p nil))
677 (defun gnus-topic-check-topology ()
678 ;; The first time we set the topology to whatever we have
679 ;; gotten here, which can be rather random.
680 (unless gnus-topic-alist
681 (gnus-topic-init-alist))
683 (setq gnus-topology-checked-p t)
684 ;; Go through the topic alist and make sure that all topics
685 ;; are in the topic topology.
686 (let ((topics (gnus-topic-list))
687 (alist gnus-topic-alist)
690 (unless (member (caar alist) topics)
691 (nconc gnus-topic-topology
692 (list (list (list (caar alist) 'visible))))
694 (setq alist (cdr alist)))
696 (gnus-topic-enter-dribble))
697 ;; Conversely, go through the topology and make sure that all
698 ;; topologies have alists.
700 (unless (assoc (car topics) gnus-topic-alist)
701 (push (list (car topics)) gnus-topic-alist))
703 ;; Go through all living groups and make sure that
704 ;; they belong to some topic.
705 (let* ((tgroups (apply 'append (mapcar (lambda (entry) (cdr entry))
707 (entry (last (assoc (caar gnus-topic-topology) gnus-topic-alist)))
708 (newsrc (cdr gnus-newsrc-alist))
711 (unless (member (setq group (gnus-info-group (pop newsrc))) tgroups)
712 (setcdr entry (list group))
713 (setq entry (cdr entry)))))
714 ;; Go through all topics and make sure they contain only living groups.
715 (let ((alist gnus-topic-alist)
717 (while (setq topic (pop alist))
719 (if (and (cadr topic)
720 (gnus-gethash (cadr topic) gnus-newsrc-hashtb))
721 (setq topic (cdr topic))
722 (setcdr topic (cddr topic)))))))
724 (defun gnus-topic-init-alist ()
725 "Initialize the topic structures."
726 (setq gnus-topic-topology
727 (cons (list "Gnus" 'visible)
728 (mapcar (lambda (topic)
729 (list (list (car topic) 'visible)))
731 (setq gnus-topic-alist
733 (mapcar (lambda (info) (gnus-info-group info))
734 (cdr gnus-newsrc-alist)))
736 (gnus-topic-enter-dribble))
740 (defun gnus-topic-clean-alist ()
741 "Remove bogus groups from the topic alist."
742 (let ((topic-alist gnus-topic-alist)
744 (unless gnus-killed-hashtb
745 (gnus-make-hashtable-from-killed))
746 (while (setq topic (pop topic-alist))
747 (let ((topic-name (pop topic))
748 group filtered-topic)
749 (while (setq group (pop topic))
750 (when (and (or (gnus-gethash group gnus-active-hashtb)
751 (gnus-info-method (gnus-get-info group)))
752 (not (gnus-gethash group gnus-killed-hashtb)))
753 (push group filtered-topic)))
754 (push (cons topic-name (nreverse filtered-topic)) result)))
755 (setq gnus-topic-alist (nreverse result))))
757 (defun gnus-topic-change-level (group level oldlevel &optional previous)
758 "Run when changing levels to enter/remove groups from topics."
760 (set-buffer gnus-group-buffer)
761 (let ((buffer-read-only nil))
762 (unless gnus-topic-inhibit-change-level
763 (gnus-group-goto-group (or (car (nth 2 previous)) group))
764 (when (and gnus-topic-mode
766 (not gnus-topic-inhibit-change-level))
767 ;; Remove the group from the topics.
768 (if (and (< oldlevel gnus-level-zombie)
769 (>= level gnus-level-zombie))
770 (let ((alist gnus-topic-alist))
771 (while (gnus-group-goto-group group)
774 (when (member group (car alist))
775 (setcdr (car alist) (delete group (cdar alist))))
777 ;; If the group is subscribed we enter it into the topics.
778 (when (and (< level gnus-level-zombie)
779 (>= oldlevel gnus-level-zombie))
780 (let* ((prev (gnus-group-group-name))
781 (gnus-topic-inhibit-change-level t)
782 (gnus-group-indentation
784 (* gnus-topic-indent-level
786 (gnus-topic-goto-topic (gnus-current-topic))
787 (gnus-group-topic-level))
790 (yanked (list group))
792 ;; Then we enter the yanked groups into the topics they belong
794 (when (setq alist (assoc (save-excursion
798 (caar gnus-topic-topology)))
801 (when (stringp yanked)
802 (setq yanked (list yanked)))
805 (if (not (cdr alist))
806 (setcdr alist (nconc yanked (cdr alist)))
807 (while (and (not end) (cdr alist))
808 (when (equal (cadr alist) prev)
809 (setcdr alist (nconc yanked (cdr alist)))
811 (setq alist (cdr alist)))
813 (nconc talist yanked))))))
814 (gnus-topic-update-topic))))))))
816 (defun gnus-topic-goto-next-group (group props)
817 "Go to group or the next group after group."
819 (if (not (memq 'gnus-topic props))
820 (goto-char (point-max))
821 (gnus-topic-goto-topic (symbol-name (cadr (memq 'gnus-topic props)))))
822 (if (gnus-group-goto-group group)
824 ;; The group is no longer visible.
825 (let* ((list (assoc (gnus-group-topic group) gnus-topic-alist))
826 (after (cdr (member group (cdr list)))))
827 ;; First try to put point on a group after the current one.
829 (not (gnus-group-goto-group (car after))))
830 (setq after (cdr after)))
831 ;; Then try to put point on a group before point.
833 (setq after (cdr (member group (reverse (cdr list)))))
835 (not (gnus-group-goto-group (car after))))
836 (setq after (cdr after))))
837 ;; Finally, just put point on the topic.
839 (goto-char (point-min))
841 (gnus-topic-goto-topic (car list))
845 ;;; Topic-active functions
847 (defun gnus-topic-grok-active (&optional force)
848 "Parse all active groups and create topic structures for them."
849 ;; First we make sure that we have really read the active file.
851 (not gnus-topic-active-alist))
853 ;; Get a list of all groups available.
854 (mapatoms (lambda (g) (when (symbol-value g)
855 (push (symbol-name g) groups)))
857 (setq groups (sort groups 'string<))
858 ;; Init the variables.
859 (setq gnus-topic-active-topology (list (list "" 'visible)))
860 (setq gnus-topic-active-alist nil)
861 ;; Descend the top-level hierarchy.
862 (gnus-topic-grok-active-1 gnus-topic-active-topology groups)
863 ;; Set the top-level topic names to something nice.
864 (setcar (car gnus-topic-active-topology) "Gnus active")
865 (setcar (car gnus-topic-active-alist) "Gnus active"))))
867 (defun gnus-topic-grok-active-1 (topology groups)
868 (let* ((name (caar topology))
869 (prefix (concat "^" (regexp-quote name)))
870 tgroups ntopology group)
872 (string-match prefix (setq group (car groups))))
873 (if (not (string-match "\\." group (match-end 0)))
874 ;; There are no further hierarchies here, so we just
875 ;; enter this group into the list belonging to this
877 (push (pop groups) tgroups)
878 ;; New sub-hierarchy, so we add it to the topology.
879 (nconc topology (list (setq ntopology
880 (list (list (substring
881 group 0 (match-end 0))
883 ;; Descend the hierarchy.
884 (setq groups (gnus-topic-grok-active-1 ntopology groups))))
885 ;; We remove the trailing "." from the topic name.
887 (if (string-match "\\.$" name)
888 (substring name 0 (match-beginning 0))
890 ;; Add this topic and its groups to the topic alist.
891 (push (cons name (nreverse tgroups)) gnus-topic-active-alist)
892 (setcar (car topology) name)
893 ;; We return the rest of the groups that didn't belong
897 ;;; Topic mode, commands and keymap.
899 (defvar gnus-topic-mode-map nil)
900 (defvar gnus-group-topic-map nil)
902 (unless gnus-topic-mode-map
903 (setq gnus-topic-mode-map (make-sparse-keymap))
905 ;; Override certain group mode keys.
906 (gnus-define-keys gnus-topic-mode-map
907 "=" gnus-topic-select-group
908 "\r" gnus-topic-select-group
909 " " gnus-topic-read-group
910 "\C-c\C-x" gnus-topic-expire-articles
911 "\C-k" gnus-topic-kill-group
912 "\C-y" gnus-topic-yank-group
913 "\M-g" gnus-topic-get-new-news-this-topic
914 "AT" gnus-topic-list-active
915 "Gp" gnus-topic-edit-parameters
916 "#" gnus-topic-mark-topic
917 "\M-#" gnus-topic-unmark-topic
918 [tab] gnus-topic-indent
919 [(meta tab)] gnus-topic-unindent
920 "\C-i" gnus-topic-indent
921 "\M-\C-i" gnus-topic-unindent
922 gnus-mouse-2 gnus-mouse-pick-topic)
924 ;; Define a new submap.
925 (gnus-define-keys (gnus-group-topic-map "T" gnus-group-mode-map)
926 "#" gnus-topic-mark-topic
927 "\M-#" gnus-topic-unmark-topic
928 "n" gnus-topic-create-topic
929 "m" gnus-topic-move-group
930 "D" gnus-topic-remove-group
931 "c" gnus-topic-copy-group
932 "h" gnus-topic-hide-topic
933 "s" gnus-topic-show-topic
934 "M" gnus-topic-move-matching
935 "C" gnus-topic-copy-matching
936 "\C-i" gnus-topic-indent
937 [tab] gnus-topic-indent
938 "r" gnus-topic-rename
939 "\177" gnus-topic-delete
940 [delete] gnus-topic-delete
941 "H" gnus-topic-toggle-display-empty-topics)
943 (gnus-define-keys (gnus-topic-sort-map "S" gnus-group-topic-map)
944 "s" gnus-topic-sort-groups
945 "a" gnus-topic-sort-groups-by-alphabet
946 "u" gnus-topic-sort-groups-by-unread
947 "l" gnus-topic-sort-groups-by-level
948 "v" gnus-topic-sort-groups-by-score
949 "r" gnus-topic-sort-groups-by-rank
950 "m" gnus-topic-sort-groups-by-method))
952 (defun gnus-topic-make-menu-bar ()
953 (unless (boundp 'gnus-topic-menu)
955 gnus-topic-menu gnus-topic-mode-map ""
957 ["Toggle topics" gnus-topic-mode t]
959 ["Copy" gnus-topic-copy-group t]
960 ["Move" gnus-topic-move-group t]
961 ["Remove" gnus-topic-remove-group t]
962 ["Copy matching" gnus-topic-copy-matching t]
963 ["Move matching" gnus-topic-move-matching t])
965 ["Show" gnus-topic-show-topic t]
966 ["Hide" gnus-topic-hide-topic t]
967 ["Delete" gnus-topic-delete t]
968 ["Rename" gnus-topic-rename t]
969 ["Create" gnus-topic-create-topic t]
970 ["Mark" gnus-topic-mark-topic t]
971 ["Indent" gnus-topic-indent t]
972 ["Toggle hide empty" gnus-topic-toggle-display-empty-topics t]
973 ["Edit parameters" gnus-topic-edit-parameters t])
974 ["List active" gnus-topic-list-active t]))))
976 (defun gnus-topic-mode (&optional arg redisplay)
977 "Minor mode for topicsifying Gnus group buffers."
978 (interactive (list current-prefix-arg t))
979 (when (eq major-mode 'gnus-group-mode)
980 (make-local-variable 'gnus-topic-mode)
981 (setq gnus-topic-mode
982 (if (null arg) (not gnus-topic-mode)
983 (> (prefix-numeric-value arg) 0)))
984 ;; Infest Gnus with topics.
985 (if (not gnus-topic-mode)
986 (setq gnus-goto-missing-group-function nil)
987 (when (gnus-visual-p 'topic-menu 'menu)
988 (gnus-topic-make-menu-bar))
989 (gnus-set-format 'topic t)
990 (gnus-add-minor-mode 'gnus-topic-mode " Topic" gnus-topic-mode-map)
991 (add-hook 'gnus-group-catchup-group-hook 'gnus-topic-update-topic)
992 (set (make-local-variable 'gnus-group-prepare-function)
993 'gnus-group-prepare-topics)
994 (set (make-local-variable 'gnus-group-get-parameter-function)
995 'gnus-group-topic-parameters)
996 (set (make-local-variable 'gnus-group-goto-next-group-function)
997 'gnus-topic-goto-next-group)
998 (set (make-local-variable 'gnus-group-indentation-function)
999 'gnus-topic-group-indentation)
1000 (set (make-local-variable 'gnus-group-update-group-function)
1001 'gnus-topic-update-topics-containing-group)
1002 (set (make-local-variable 'gnus-group-sort-alist-function)
1003 'gnus-group-sort-topic)
1004 (setq gnus-group-change-level-function 'gnus-topic-change-level)
1005 (setq gnus-goto-missing-group-function 'gnus-topic-goto-missing-group)
1006 (make-local-hook 'gnus-check-bogus-groups-hook)
1007 (add-hook 'gnus-check-bogus-groups-hook 'gnus-topic-clean-alist)
1008 (setq gnus-topology-checked-p nil)
1009 ;; We check the topology.
1010 (when gnus-newsrc-alist
1011 (gnus-topic-check-topology))
1012 (gnus-run-hooks 'gnus-topic-mode-hook))
1013 ;; Remove topic infestation.
1014 (unless gnus-topic-mode
1015 (remove-hook 'gnus-summary-exit-hook 'gnus-topic-update-topic)
1016 (remove-hook 'gnus-group-change-level-function
1017 'gnus-topic-change-level)
1018 (remove-hook 'gnus-check-bogus-groups-hook 'gnus-topic-clean-alist)
1019 (setq gnus-group-prepare-function 'gnus-group-prepare-flat)
1020 (setq gnus-group-sort-alist-function 'gnus-group-sort-flat))
1022 (gnus-group-list-groups))))
1024 (defun gnus-topic-select-group (&optional all)
1025 "Select this newsgroup.
1026 No article is selected automatically.
1027 If ALL is non-nil, already read articles become readable.
1028 If ALL is a number, fetch this number of articles.
1030 If performed over a topic line, toggle folding the topic."
1032 (if (gnus-group-topic-p)
1033 (let ((gnus-group-list-mode
1034 (if all (cons (if (numberp all) all 7) t) gnus-group-list-mode)))
1035 (gnus-topic-fold all))
1036 (gnus-group-select-group all)))
1038 (defun gnus-mouse-pick-topic (e)
1039 "Select the group or topic under the mouse pointer."
1042 (gnus-topic-read-group nil))
1044 (defun gnus-topic-expire-articles (topic)
1045 "Expire articles in this topic or group."
1046 (interactive (list (gnus-group-topic-name)))
1048 (call-interactively 'gnus-group-expire-articles)
1050 (gnus-message 5 "Expiring groups in %s..." topic)
1051 (let ((gnus-group-marked
1052 (mapcar (lambda (entry) (car (nth 2 entry)))
1053 (gnus-topic-find-groups topic gnus-level-killed t))))
1054 (gnus-group-expire-articles nil))
1055 (gnus-message 5 "Expiring groups in %s...done" topic))))
1057 (defun gnus-topic-read-group (&optional all no-article group)
1058 "Read news in this newsgroup.
1059 If the prefix argument ALL is non-nil, already read articles become
1060 readable. IF ALL is a number, fetch this number of articles. If the
1061 optional argument NO-ARTICLE is non-nil, no article will be
1062 auto-selected upon group entry. If GROUP is non-nil, fetch that
1065 If performed over a topic line, toggle folding the topic."
1067 (if (gnus-group-topic-p)
1068 (let ((gnus-group-list-mode
1069 (if all (cons (if (numberp all) all 7) t) gnus-group-list-mode)))
1070 (gnus-topic-fold all))
1071 (gnus-group-read-group all no-article group)))
1073 (defun gnus-topic-create-topic (topic parent &optional previous full-topic)
1074 "Create a new TOPIC under PARENT.
1075 When used interactively, PARENT will be the topic under point."
1078 (read-string "New topic: ")
1079 (gnus-current-topic)))
1080 ;; Check whether this topic already exists.
1081 (when (gnus-topic-find-topology topic)
1082 (error "Topic already exists"))
1084 (setq parent (caar gnus-topic-topology)))
1085 (let ((top (cdr (gnus-topic-find-topology parent)))
1086 (full-topic (or full-topic `((,topic visible)))))
1088 (error "No such parent topic: %s" parent))
1091 (while (and (cdr top)
1092 (not (equal (caaadr top) previous)))
1093 (setq top (cdr top)))
1094 (setcdr top (cons full-topic (cdr top))))
1095 (nconc top (list full-topic)))
1096 (unless (assoc topic gnus-topic-alist)
1097 (push (list topic) gnus-topic-alist)))
1098 (gnus-topic-enter-dribble)
1099 (gnus-group-list-groups)
1100 (gnus-topic-goto-topic topic))
1102 (defun gnus-topic-move-group (n topic &optional copyp)
1103 "Move the next N groups to TOPIC.
1104 If COPYP, copy the groups instead."
1106 (list current-prefix-arg
1107 (completing-read "Move to topic: " gnus-topic-alist nil t)))
1108 (let ((groups (gnus-group-process-prefix n))
1109 (topicl (assoc topic gnus-topic-alist))
1110 (start-group (progn (forward-line 1) (gnus-group-group-name)))
1111 (start-topic (gnus-group-topic-name))
1115 (gnus-group-remove-mark g)
1117 (setq entry (assoc (gnus-current-topic) gnus-topic-alist))
1119 (setcdr entry (gnus-delete-first g (cdr entry))))
1120 (nconc topicl (list g)))
1122 (gnus-topic-enter-dribble)
1124 (gnus-group-goto-group start-group)
1125 (gnus-topic-goto-topic start-topic))
1126 (gnus-group-list-groups)))
1128 (defun gnus-topic-remove-group (&optional arg)
1129 "Remove the current group from the topic."
1131 (gnus-group-iterate arg
1133 (let ((topicl (assoc (gnus-current-topic) gnus-topic-alist))
1134 (buffer-read-only nil))
1135 (when (and topicl group)
1137 (gnus-delete-first group topicl))
1138 (gnus-topic-update-topic)
1139 (gnus-group-position-point)))))
1141 (defun gnus-topic-copy-group (n topic)
1142 "Copy the current group to a topic."
1144 (list current-prefix-arg
1145 (completing-read "Copy to topic: " gnus-topic-alist nil t)))
1146 (gnus-topic-move-group n topic t))
1148 (defun gnus-topic-kill-group (&optional n discard)
1149 "Kill the next N groups."
1151 (if (gnus-group-topic-p)
1152 (let ((topic (gnus-group-topic-name)))
1154 (gnus-topic-find-topology topic)
1155 (assoc topic gnus-topic-alist))
1156 gnus-topic-killed-topics)
1157 (gnus-topic-remove-topic nil t)
1158 (gnus-topic-find-topology topic nil nil gnus-topic-topology)
1159 (gnus-topic-enter-dribble))
1160 (gnus-group-kill-group n discard)
1161 (gnus-topic-update-topic)))
1163 (defun gnus-topic-yank-group (&optional arg)
1164 "Yank the last topic."
1166 (if gnus-topic-killed-topics
1168 (or (gnus-group-topic-name)
1169 (gnus-topic-next-topic (gnus-current-topic))))
1170 (data (pop gnus-topic-killed-topics))
1173 (push alist gnus-topic-alist)
1174 (gnus-topic-create-topic
1175 (caar item) (gnus-topic-parent-topic previous) previous
1177 (gnus-topic-enter-dribble)
1178 (gnus-topic-goto-topic (caar item)))
1179 (let* ((prev (gnus-group-group-name))
1180 (gnus-topic-inhibit-change-level t)
1181 (gnus-group-indentation
1183 (* gnus-topic-indent-level
1185 (gnus-topic-goto-topic (gnus-current-topic))
1186 (gnus-group-topic-level))
1190 ;; We first yank the groups the normal way...
1191 (setq yanked (gnus-group-yank-group arg))
1192 ;; Then we enter the yanked groups into the topics they belong
1194 (setq alist (assoc (save-excursion
1196 (gnus-current-topic))
1198 (when (stringp yanked)
1199 (setq yanked (list yanked)))
1201 (nconc alist yanked)
1202 (if (not (cdr alist))
1203 (setcdr alist (nconc yanked (cdr alist)))
1205 (when (equal (cadr alist) prev)
1206 (setcdr alist (nconc yanked (cdr alist)))
1208 (setq alist (cdr alist))))))
1209 (gnus-topic-update-topic)))
1211 (defun gnus-topic-hide-topic ()
1212 "Hide the current topic."
1214 (when (gnus-current-topic)
1215 (gnus-topic-goto-topic (gnus-current-topic))
1216 (gnus-topic-remove-topic nil nil 'hidden)))
1218 (defun gnus-topic-show-topic ()
1219 "Show the hidden topic."
1221 (when (gnus-group-topic-p)
1222 (gnus-topic-remove-topic t nil 'shown)))
1224 (defun gnus-topic-mark-topic (topic &optional unmark)
1225 "Mark all groups in the topic with the process mark."
1226 (interactive (list (gnus-group-topic-name)))
1228 (call-interactively 'gnus-group-mark-group)
1230 (let ((groups (gnus-topic-find-groups topic gnus-level-killed t)))
1232 (funcall (if unmark 'gnus-group-remove-mark 'gnus-group-set-mark)
1233 (gnus-info-group (nth 2 (pop groups)))))))))
1235 (defun gnus-topic-unmark-topic (topic &optional unmark)
1236 "Remove the process mark from all groups in the topic."
1237 (interactive (list (gnus-group-topic-name)))
1239 (call-interactively 'gnus-group-unmark-group)
1240 (gnus-topic-mark-topic topic t)))
1242 (defun gnus-topic-get-new-news-this-topic (&optional n)
1243 "Check for new news in the current topic."
1245 (if (not (gnus-group-topic-p))
1246 (gnus-group-get-new-news-this-group n)
1247 (gnus-topic-mark-topic (gnus-group-topic-name))
1248 (gnus-group-get-new-news-this-group)))
1250 (defun gnus-topic-move-matching (regexp topic &optional copyp)
1251 "Move all groups that match REGEXP to some topic."
1256 (setq topic (completing-read "Move to topic: " gnus-topic-alist nil t))
1257 (read-string (format "Move to %s (regexp): " topic))))))
1258 (gnus-group-mark-regexp regexp)
1259 (gnus-topic-move-group nil topic copyp))
1261 (defun gnus-topic-copy-matching (regexp topic &optional copyp)
1262 "Copy all groups that match REGEXP to some topic."
1267 (setq topic (completing-read "Copy to topic: " gnus-topic-alist nil t))
1268 (read-string (format "Copy to %s (regexp): " topic))))))
1269 (gnus-topic-move-matching regexp topic t))
1271 (defun gnus-topic-delete (topic)
1273 (interactive (list (gnus-group-topic-name)))
1275 (error "No topic to be deleted"))
1276 (let ((entry (assoc topic gnus-topic-alist))
1277 (buffer-read-only nil))
1279 (error "Topic not empty"))
1280 ;; Delete if visible.
1281 (when (gnus-topic-goto-topic topic)
1283 ;; Remove from alist.
1284 (setq gnus-topic-alist (delq entry gnus-topic-alist))
1285 ;; Remove from topology.
1286 (gnus-topic-find-topology topic nil nil 'delete)
1287 (gnus-dribble-touch)))
1289 (defun gnus-topic-rename (old-name new-name)
1292 (let ((topic (gnus-current-topic)))
1294 (read-string (format "Rename %s to: " topic)))))
1295 ;; Check whether the new name exists.
1296 (when (gnus-topic-find-topology new-name)
1297 (error "Topic '%s' already exists" new-name))
1298 ;; "nil" is an invalid name, for reasons I'd rather not go
1299 ;; into here. Trust me.
1300 (when (equal new-name "nil")
1301 (error "Invalid name: %s" nil))
1303 (let ((top (gnus-topic-find-topology old-name))
1304 (entry (assoc old-name gnus-topic-alist)))
1306 (setcar (cadr top) new-name))
1308 (setcar entry new-name))
1310 (gnus-dribble-touch)
1311 (gnus-group-list-groups)
1314 (defun gnus-topic-indent (&optional unindent)
1315 "Indent a topic -- make it a sub-topic of the previous topic.
1316 If UNINDENT, remove an indentation."
1319 (gnus-topic-unindent)
1320 (let* ((topic (gnus-current-topic))
1321 (parent (gnus-topic-previous-topic topic))
1322 (buffer-read-only nil))
1324 (error "Nothing to indent %s into" topic))
1326 (gnus-topic-goto-topic topic)
1327 (gnus-topic-kill-group)
1328 (push (cdar gnus-topic-killed-topics) gnus-topic-alist)
1329 (gnus-topic-create-topic
1330 topic parent nil (cdaar gnus-topic-killed-topics))
1331 (pop gnus-topic-killed-topics)
1332 (or (gnus-topic-goto-topic topic)
1333 (gnus-topic-goto-topic parent))))))
1335 (defun gnus-topic-unindent ()
1338 (let* ((topic (gnus-current-topic))
1339 (parent (gnus-topic-parent-topic topic))
1340 (grandparent (gnus-topic-parent-topic parent)))
1342 (error "Nothing to indent %s into" topic))
1344 (gnus-topic-goto-topic topic)
1345 (gnus-topic-kill-group)
1346 (push (cdar gnus-topic-killed-topics) gnus-topic-alist)
1347 (gnus-topic-create-topic
1348 topic grandparent (gnus-topic-next-topic parent)
1349 (cdaar gnus-topic-killed-topics))
1350 (pop gnus-topic-killed-topics)
1351 (gnus-topic-goto-topic topic))))
1353 (defun gnus-topic-list-active (&optional force)
1354 "List all groups that Gnus knows about in a topicsified fashion.
1355 If FORCE, always re-read the active file."
1358 (gnus-get-killed-groups))
1359 (gnus-topic-grok-active force)
1360 (let ((gnus-topic-topology gnus-topic-active-topology)
1361 (gnus-topic-alist gnus-topic-active-alist)
1362 gnus-killed-list gnus-zombie-list)
1363 (gnus-group-list-groups gnus-level-killed nil 1)))
1365 (defun gnus-topic-toggle-display-empty-topics ()
1366 "Show/hide topics that have no unread articles."
1368 (setq gnus-topic-display-empty-topics
1369 (not gnus-topic-display-empty-topics))
1370 (gnus-group-list-groups)
1371 (message "%s empty topics"
1372 (if gnus-topic-display-empty-topics
1373 "Showing" "Hiding")))
1375 ;;; Topic sorting functions
1377 (defun gnus-topic-edit-parameters (group)
1378 "Edit the group parameters of GROUP.
1379 If performed on a topic, edit the topic parameters instead."
1380 (interactive (list (gnus-group-group-name)))
1382 (gnus-group-edit-group-parameters group)
1383 (if (not (gnus-group-topic-p))
1384 (error "Nothing to edit on the current line")
1385 (let ((topic (gnus-group-topic-name)))
1387 (gnus-topic-parameters topic)
1388 (format "Editing the topic parameters for `%s'."
1391 (gnus-topic-set-parameters ,topic form)))))))
1393 (defun gnus-group-sort-topic (func reverse)
1394 "Sort groups in the topics according to FUNC and REVERSE."
1395 (let ((alist gnus-topic-alist))
1397 ;; !!!Sometimes nil elements sneak into the alist,
1398 ;; for some reason or other.
1399 (setcar alist (delq nil (car alist)))
1400 (setcar alist (delete "dummy.group" (car alist)))
1401 (gnus-topic-sort-topic (pop alist) func reverse))))
1403 (defun gnus-topic-sort-topic (topic func reverse)
1404 ;; Each topic only lists the name of the group, while
1405 ;; the sort predicates expect group infos as inputs.
1406 ;; So we first transform the group names into infos,
1407 ;; then sort, and then transform back into group names.
1411 (lambda (info) (gnus-info-group info))
1414 (lambda (group) (gnus-get-info group))
1417 ;; Do the reversal, if necessary.
1419 (setcdr topic (nreverse (cdr topic)))))
1421 (defun gnus-topic-sort-groups (func &optional reverse)
1422 "Sort the current topic according to FUNC.
1423 If REVERSE, reverse the sorting order."
1424 (interactive (list gnus-group-sort-function current-prefix-arg))
1425 (let ((topic (assoc (gnus-current-topic) gnus-topic-alist)))
1426 (gnus-topic-sort-topic
1427 topic (gnus-make-sort-function func) reverse)
1428 (gnus-group-list-groups)))
1430 (defun gnus-topic-sort-groups-by-alphabet (&optional reverse)
1431 "Sort the current topic alphabetically by group name.
1432 If REVERSE, sort in reverse order."
1434 (gnus-topic-sort-groups 'gnus-group-sort-by-alphabet reverse))
1436 (defun gnus-topic-sort-groups-by-unread (&optional reverse)
1437 "Sort the current topic by number of unread articles.
1438 If REVERSE, sort in reverse order."
1440 (gnus-topic-sort-groups 'gnus-group-sort-by-unread reverse))
1442 (defun gnus-topic-sort-groups-by-level (&optional reverse)
1443 "Sort the current topic by group level.
1444 If REVERSE, sort in reverse order."
1446 (gnus-topic-sort-groups 'gnus-group-sort-by-level reverse))
1448 (defun gnus-topic-sort-groups-by-score (&optional reverse)
1449 "Sort the current topic by group score.
1450 If REVERSE, sort in reverse order."
1452 (gnus-topic-sort-groups 'gnus-group-sort-by-score reverse))
1454 (defun gnus-topic-sort-groups-by-rank (&optional reverse)
1455 "Sort the current topic by group rank.
1456 If REVERSE, sort in reverse order."
1458 (gnus-topic-sort-groups 'gnus-group-sort-by-rank reverse))
1460 (defun gnus-topic-sort-groups-by-method (&optional reverse)
1461 "Sort the current topic alphabetically by backend name.
1462 If REVERSE, sort in reverse order."
1464 (gnus-topic-sort-groups 'gnus-group-sort-by-method reverse))
1466 (provide 'gnus-topic)
1468 ;;; gnus-topic.el ends here