-(defun gnus-topic-sort-groups-by-server (&optional reverse)
- "Sort the current topic alphabetically by server name.
-If REVERSE, sort in reverse order."
- (interactive "P")
- (gnus-topic-sort-groups 'gnus-group-sort-by-server reverse))
-
-(defun gnus-topic-sort-topics-1 (top reverse)
- (if (cdr top)
- (let ((subtop
- (mapcar (gnus-byte-compile
- `(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)))
-
-(defun gnus-subscribe-topics (newsgroup)
- (catch 'end
- (let (match gnus-group-change-level-function)
- (dolist (topic (gnus-topic-list))
- (when (and (setq match (cdr (assq 'subscribe
- (gnus-topic-parameters topic))))
- (string-match match newsgroup))
- ;; Just subscribe the group.
- (gnus-subscribe-alphabetically newsgroup)
- ;; Add the group to the topic.
- (nconc (assoc topic gnus-topic-alist) (list newsgroup))
- ;; if this topic specifies a default level, use it
- (let ((subscribe-level (cdr (assq 'subscribe-level
- (gnus-topic-parameters topic)))))
- (when subscribe-level
- (gnus-group-change-level newsgroup subscribe-level
- gnus-level-default-subscribed)))
- (throw 'end t)))
- nil)))
-