Sort threads recursively.
authorShengHuo ZHU <zsh@cs.rochester.edu>
Wed, 13 Sep 2000 20:07:16 +0000 (20:07 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Wed, 13 Sep 2000 20:07:16 +0000 (20:07 +0000)
lisp/ChangeLog
lisp/gnus-sum.el

index 0c02105..9864d83 100644 (file)
@@ -1,3 +1,10 @@
+2000-09-13 16:59:33  ShengHuo ZHU  <zsh@cs.rochester.edu>
+
+       * gnus-sum.el (gnus-summary-sort): Sort loose threads too.
+       (gnus-sort-threads-1): New function. Sort threads recursively.
+       (gnus-sort-threads): Use it.
+       (gnus-sort-gathered-threads): Doc fix.
+
 2000-09-13  Dave Love  <fx@gnu.org>
 
        * gnus-salt.el (gnus-binary-mode): Fix call to gnus-add-minor-mode.
index 5cd5486..eb7e9df 100644 (file)
@@ -3064,7 +3064,7 @@ If NO-DISPLAY, don't generate a summary buffer."
     result))
 
 (defun gnus-sort-gathered-threads (threads)
-  "Sort subtreads inside each gathered thread by article number."
+  "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
   (let ((result threads))
     (while threads
       (when (stringp (caar threads))
@@ -3639,13 +3639,22 @@ If LINE, insert the rebuilt thread starting on line LINE."
              (1+ (gnus-point-at-eol))
            (gnus-delete-line)))))))
 
+(defun gnus-sort-threads-1 (threads func)
+  (sort (mapcar (lambda (thread)
+                 (cons (car thread)
+                       (and (cdr thread)
+                            (gnus-sort-threads-1 (cdr thread) func))))
+               threads) func))
+
 (defun gnus-sort-threads (threads)
   "Sort THREADS."
   (if (not gnus-thread-sort-functions)
       threads
     (gnus-message 8 "Sorting threads...")
     (prog1
-       (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
+       (gnus-sort-threads-1 
+        threads 
+        (gnus-make-sort-function gnus-thread-sort-functions))
       (gnus-message 8 "Sorting threads...done"))))
 
 (defun gnus-sort-articles (articles)
@@ -8954,6 +8963,8 @@ Argument REVERSE means reverse order."
              thread
            `(lambda (t1 t2)
               (,thread t2 t1))))
+        (gnus-sort-gathered-threads-function
+         gnus-thread-sort-functions)
         (gnus-article-sort-functions
          (if (not reverse)
              article