@@ -3300,21 +3300,31 @@ If REVERSE (the prefix), reverse the sorting order."
3300
3300
(funcall gnus-group-sort-alist-function
3301
3301
(gnus-make-sort-function func) reverse )
3302
3302
(gnus-group-unmark-all-groups)
3303
+ ; ; Redisplay all groups according to the newly-sorted order of
3304
+ ; ; `gnus-group-list' .
3303
3305
(gnus-group-list-groups )
3304
3306
(gnus-dribble-touch ))
3305
3307
3306
3308
(defun gnus-group-sort-flat (func reverse )
3307
- ; ; We peel off the dummy group from the alist.
3309
+ " Sort groups in a flat list using sorting function FUNC.
3310
+ If REVERSE is non-nil, reverse the sort order.
3311
+
3312
+ This function sets a new value for `gnus-group-list' ; its return
3313
+ value is disregarded."
3308
3314
(when func
3309
- (when (equal (gnus-info-group (car gnus-newsrc-alist)) " dummy.group" )
3310
- (pop gnus-newsrc-alist))
3311
- ; ; Do the sorting.
3312
- (setq gnus-newsrc-alist
3313
- (sort gnus-newsrc-alist func))
3314
- (when reverse
3315
- (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3316
- ; ; Regenerate the hash table.
3317
- (gnus-make-hashtable-from-newsrc-alist)))
3315
+ (let* ((groups (remove " dummy.group" gnus-group-list))
3316
+ (sorted-infos
3317
+ (sort (mapcar (lambda (g )
3318
+ (gnus-get-info g))
3319
+ groups)
3320
+ func)))
3321
+ (setq gnus-group-list
3322
+ (mapcar (lambda (i )
3323
+ (gnus-info-group i))
3324
+ sorted-infos))
3325
+ (when reverse
3326
+ (setq gnus-group-list (nreverse gnus-group-list)))
3327
+ (setq gnus-group-list (cons " dummy.group" gnus-group-list)))))
3318
3328
3319
3329
(defun gnus-group-sort-groups-by-alphabet (&optional reverse )
3320
3330
" Sort the group buffer alphabetically by group name.
@@ -3377,27 +3387,26 @@ If REVERSE, sort in reverse order."
3377
3387
(gnus-dribble-touch )))
3378
3388
3379
3389
(defun gnus-group-sort-selected-flat (groups func reverse )
3380
- (let (entries infos)
3381
- ; ; First find all the group entries for these groups.
3382
- (while groups
3383
- (push (nthcdr 2 (gnus-group-entry (pop groups)))
3384
- entries))
3385
- ; ; Then sort the infos.
3386
- (setq infos
3387
- (sort
3388
- (mapcar
3389
- (lambda (entry ) (car entry))
3390
- (setq entries (nreverse entries)))
3391
- func))
3390
+ " Sort only the selected GROUPS, using FUNC.
3391
+ If REVERSE is non-nil, reverse the sorting."
3392
+ (let ((infos (sort
3393
+ (mapcar (lambda (g )
3394
+ (gnus-get-info g))
3395
+ groups)
3396
+ func))
3397
+ sorted-groups)
3392
3398
(when reverse
3393
3399
(setq infos (nreverse infos)))
3394
- ; ; Go through all the infos and replace the old entries
3395
- ; ; with the new infos.
3396
- (while infos
3397
- (setcar (car entries) (pop infos))
3398
- (pop entries))
3399
- ; ; Update the hashtable.
3400
- (gnus-make-hashtable-from-newsrc-alist)))
3400
+ (setq sorted-groups (mapcar (lambda (i ) (gnus-info-group i)) infos))
3401
+
3402
+ ; ; Find the original locations of GROUPS in `gnus-group-list' , and
3403
+ ; ; replace each one, in order, with a group from SORTED-GROUPS.
3404
+ (dolist (i (sort (mapcar (lambda (g )
3405
+ (seq-position gnus-group-list g))
3406
+ groups)
3407
+ #'< ))
3408
+ (setf (nth i gnus-group-list)
3409
+ (pop sorted-groups)))))
3401
3410
3402
3411
(defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse )
3403
3412
" Sort the group buffer alphabetically by group name.
0 commit comments