(funcall gnus-group-sort-alist-function
(gnus-make-sort-function func) reverse)
(gnus-group-unmark-all-groups)
+ ;; Redisplay all groups according to the newly-sorted order of
+ ;; `gnus-group-list'.
(gnus-group-list-groups)
(gnus-dribble-touch))
(defun gnus-group-sort-flat (func reverse)
- ;; We peel off the dummy group from the alist.
+ "Sort groups in a flat list using sorting function FUNC.
+If REVERSE is non-nil, reverse the sort order.
+
+This function sets a new value for `gnus-group-list'; its return
+value is disregarded."
(when func
- (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
- (pop gnus-newsrc-alist))
- ;; Do the sorting.
- (setq gnus-newsrc-alist
- (sort gnus-newsrc-alist func))
- (when reverse
- (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
- ;; Regenerate the hash table.
- (gnus-make-hashtable-from-newsrc-alist)))
+ (let* ((groups (remove "dummy.group" gnus-group-list))
+ (sorted-infos
+ (sort (mapcar (lambda (g)
+ (gnus-get-info g))
+ groups)
+ func)))
+ (setq gnus-group-list
+ (mapcar (lambda (i)
+ (gnus-info-group i))
+ sorted-infos))
+ (when reverse
+ (setq gnus-group-list (nreverse gnus-group-list)))
+ (setq gnus-group-list (cons "dummy.group" gnus-group-list)))))
(defun gnus-group-sort-groups-by-alphabet (&optional reverse)
"Sort the group buffer alphabetically by group name.
(gnus-dribble-touch)))
(defun gnus-group-sort-selected-flat (groups func reverse)
- (let (entries infos)
- ;; First find all the group entries for these groups.
- (while groups
- (push (nthcdr 2 (gnus-group-entry (pop groups)))
- entries))
- ;; Then sort the infos.
- (setq infos
- (sort
- (mapcar
- (lambda (entry) (car entry))
- (setq entries (nreverse entries)))
- func))
+ "Sort only the selected GROUPS, using FUNC.
+If REVERSE is non-nil, reverse the sorting."
+ (let ((infos (sort
+ (mapcar (lambda (g)
+ (gnus-get-info g))
+ groups)
+ func))
+ sorted-groups)
(when reverse
(setq infos (nreverse infos)))
- ;; Go through all the infos and replace the old entries
- ;; with the new infos.
- (while infos
- (setcar (car entries) (pop infos))
- (pop entries))
- ;; Update the hashtable.
- (gnus-make-hashtable-from-newsrc-alist)))
+ (setq sorted-groups (mapcar (lambda (i) (gnus-info-group i)) infos))
+
+ ;; Find the original locations of GROUPS in `gnus-group-list', and
+ ;; replace each one, in order, with a group from SORTED-GROUPS.
+ (dolist (i (sort (mapcar (lambda (g)
+ (seq-position gnus-group-list g))
+ groups)
+ #'<))
+ (setf (nth i gnus-group-list)
+ (pop sorted-groups)))))
(defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
"Sort the group buffer alphabetically by group name.
(defun gnus-subscribe-alphabetically (newgroup)
"Subscribe new NEWGROUP and insert it in alphabetical order."
- (let ((groups (cdr gnus-newsrc-alist))
- before)
- (while (and (not before) groups)
- (if (string< newgroup (caar groups))
- (setq before (caar groups))
- (setq groups (cdr groups))))
+ (let ((before (seq-find (lambda (group)
+ (string< newgroup group))
+ (cdr gnus-group-list))))
(gnus-subscribe-newsgroup newgroup before)))
(defun gnus-subscribe-hierarchically (newgroup)
it is killed."
(if (gnus-y-or-n-p (format "Subscribe new newsgroup %s? " group))
(gnus-subscribe-hierarchically group)
- (push group gnus-killed-list)))
+ (gnus-subscribe-killed group)))
(defun gnus-subscribe-zombies (group)
"Make the new GROUP into a zombie group."
- (push group gnus-zombie-list))
+ (cl-pushnew group gnus-zombie-list :test #'equal))
(defun gnus-subscribe-killed (group)
"Make the new GROUP a killed group."
- (push group gnus-killed-list))
+ (cl-pushnew group gnus-killed-list :test #'equal))
(defun gnus-subscribe-newsgroup (newsgroup &optional next)
"Subscribe new NEWSGROUP.