[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting with threads in Gnus

From: Tassilo Horn
Subject: Re: Sorting with threads in Gnus
Date: Fri, 26 Jul 2013 15:26:38 +0200
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux)

Tassilo Horn <> writes:

>> But I'll bet with a little care, it would be possible to make a
>> gnus-sort-threads-recursively-p option, which would have
>> gnus-sort-threads break to gnus-sort-articles after the first round
>> of sorting... Maybe.
> That would be awesome.

That was easier than expected.  The following patch (with setting
gnus-sort-threads-recursively to nil) seems to achieve exactly what I

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el
index f3918b0..15cbb5a 100644
--- a/lisp/gnus-sum.el
+++ b/lisp/gnus-sum.el
@@ -847,6 +847,13 @@ controls how articles are sorted."
                           (function :tag "other"))
                   (boolean :tag "Reverse order"))))
+(defcustom gnus-sort-threads-recursively t
+  "If non-nil, `gnus-thread-sort-functions' are applied recursively.
+Setting this to nil allows sorting high-score, recent,
+etc. threads to the top of the summary buffer while still
+retaining chronological old to new sorting order inside threads."
+  :group 'gnus-summary-sort
+  :type 'boolean)
 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
   "*List of functions used for sorting threads in the summary buffer.
@@ -4876,9 +4883,11 @@ If LINE, insert the rebuilt thread starting on line 
     (gnus-message 8 "Sorting threads...")
        (condition-case nil
-           (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
-             (gnus-sort-threads-recursive
-              threads (gnus-make-sort-function gnus-thread-sort-functions)))
+           (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
+                 (sort-func (gnus-make-sort-function 
+             (if gnus-sort-threads-recursively
+                 (gnus-sort-threads-recursive threads sort-func)
+               (sort threads sort-func)))
          ;; Even after binding max-lisp-eval-depth, the recursive
          ;; sorter might fail for very long threads.  In that case,
          ;; try using a (less well-tested) non-recursive sorter.
--8<---------------cut here---------------end--------------->8---

It would be good if others could test-drive it a bit more.  If it
doesn't break anything, I'm going to add some docs and commit it in the
Gnus master branch.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]