aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTassilo Horn2013-07-30 08:16:20 +0000
committerKatsumi Yamaoka2013-07-30 08:16:20 +0000
commita3fd87cb69eb4e93238a2701118559bee9d493eb (patch)
treea91fffe5c2f3f193fc7ad5ca4733630b29730db6
parent1e6c60074fd3d412f3ec982c583937e01b2eb3b0 (diff)
downloademacs-a3fd87cb69eb4e93238a2701118559bee9d493eb.tar.gz
emacs-a3fd87cb69eb4e93238a2701118559bee9d493eb.zip
Gnus: Improve subthread sorting;
make subthread sorting customizable and add docs for it * doc/misc/gnus.texi (Sorting the Summary Buffer): Document new defcustom `gnus-subthread-sort-functions' and remove the obsolete documentation of `gnus-sort-threads-recursively'. * lisp/gnus/gnus-sum.el (gnus-subthread-sort-functions): New defcustom. (gnus-sort-threads-recursively): Delete defcustom. (gnus-sort-threads-recursive): Adapt accordingly. * lisp/gnus/gnus-sum.el (gnus-sort-subthreads-recursive): New function. (gnus-sort-threads-recursive): Use it. (gnus-sort-threads): Unconditionally call `gnus-sort-threads-recursive' again. Now that determines how to sort subthreads.
-rw-r--r--doc/misc/ChangeLog8
-rw-r--r--doc/misc/gnus.texi11
-rw-r--r--lisp/gnus/ChangeLog13
-rw-r--r--lisp/gnus/gnus-sum.el57
4 files changed, 71 insertions, 18 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index b306ce5ba0a..9b45ac06f4c 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,4 +1,10 @@
12013-07-29 David Engster <deng@randomsample.de> 12013-07-30 Tassilo Horn <tsdh@gnu.org>
2
3 * gnus.texi (Sorting the Summary Buffer): Document new defcustom
4 `gnus-subthread-sort-functions' and remove the obsolete documentation
5 of `gnus-sort-threads-recursively'.
6
72013-07-29 David Engster <deng@randomsample.de>
2 8
3 * eieio.texi (top): Make clear that EIEIO is not a full CLOS 9 * eieio.texi (top): Make clear that EIEIO is not a full CLOS
4 implementation. 10 implementation.
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 5f9e0b9db28..808bd2b114b 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -7394,10 +7394,13 @@ say something like:
7394 gnus-thread-sort-by-score)) 7394 gnus-thread-sort-by-score))
7395@end lisp 7395@end lisp
7396 7396
7397By default, threads are sorted recursively, that is, first the roots, 7397By default, threads including their subthreads are sorted according to
7398then all subthreads, and so on. If you feel more like sorting only 7398the value of @code{gnus-thread-sort-functions}. By customizing
7399the roots, so that inside a thread the original chronological order is 7399@code{gnus-subthread-sort-functions} you can define a custom sorting
7400retained, you can set @code{gnus-sort-threads-recursively} to nil. 7400order for subthreads. This allows for example to sort threads from
7401high score to low score in the summary buffer, but to have subthreads
7402still sorted chronologically from old to new without taking their
7403score into account.
7401 7404
7402@vindex gnus-thread-score-function 7405@vindex gnus-thread-score-function
7403The function in the @code{gnus-thread-score-function} variable (default 7406The function in the @code{gnus-thread-score-function} variable (default
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index c32853a2a9f..4230d010a5d 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,16 @@
12013-07-30 Tassilo Horn <tsdh@gnu.org>
2
3 * gnus-sum.el (gnus-subthread-sort-functions): New defcustom.
4 (gnus-sort-threads-recursively): Delete defcustom.
5 (gnus-sort-threads-recursive): Adapt accordingly.
6
72013-07-30 Tassilo Horn <tsdh@gnu.org>
8
9 * gnus-sum.el (gnus-sort-subthreads-recursive): New function.
10 (gnus-sort-threads-recursive): Use it.
11 (gnus-sort-threads): Unconditionally call `gnus-sort-threads-recursive'
12 again. Now that determines how to sort subthreads.
13
12013-07-26 Tassilo Horn <tsdh@gnu.org> 142013-07-26 Tassilo Horn <tsdh@gnu.org>
2 15
3 * gnus-sum.el (gnus-sort-threads-recursively): New defcustom. 16 * gnus-sum.el (gnus-sort-threads-recursively): New defcustom.
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 15cbb5a45e6..a7269baee74 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -847,14 +847,6 @@ controls how articles are sorted."
847 (function :tag "other")) 847 (function :tag "other"))
848 (boolean :tag "Reverse order")))) 848 (boolean :tag "Reverse order"))))
849 849
850(defcustom gnus-sort-threads-recursively t
851 "If non-nil, `gnus-thread-sort-functions' are applied recursively.
852Setting this to nil allows sorting high-score, recent,
853etc. threads to the top of the summary buffer while still
854retaining chronological old to new sorting order inside threads."
855 :group 'gnus-summary-sort
856 :type 'boolean)
857
858(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number) 850(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
859 "*List of functions used for sorting threads in the summary buffer. 851 "*List of functions used for sorting threads in the summary buffer.
860By default, threads are sorted by article number. 852By default, threads are sorted by article number.
@@ -880,7 +872,11 @@ and `gnus-thread-sort-by-total-score' (see
880`gnus-thread-score-function'). 872`gnus-thread-score-function').
881 873
882When threading is turned off, the variable 874When threading is turned off, the variable
883`gnus-article-sort-functions' controls how articles are sorted." 875`gnus-article-sort-functions' controls how articles are sorted.
876
877By default, threads and their subthreads are sorted according to
878the value of this variable. To use a different sorting order for
879subthreads, customize `gnus-subthread-sort-functions'."
884 :group 'gnus-summary-sort 880 :group 'gnus-summary-sort
885 :type '(repeat 881 :type '(repeat
886 (gnus-widget-reversible 882 (gnus-widget-reversible
@@ -897,6 +893,28 @@ When threading is turned off, the variable
897 (function :tag "other")) 893 (function :tag "other"))
898 (boolean :tag "Reverse order")))) 894 (boolean :tag "Reverse order"))))
899 895
896(defcustom gnus-subthread-sort-functions 'gnus-thread-sort-functions
897 "*List of functions used for sorting subthreads in the summary buffer.
898By default, subthreads are sorted the same as threads, i.e.,
899according to the value of `gnus-thread-sort-functions'."
900 :group 'gnus-summary-sort
901 :type '(choice
902 (const :tag "Sort subthreads like threads" gnus-thread-sort-functions)
903 (repeat
904 (gnus-widget-reversible
905 (choice (function-item gnus-thread-sort-by-number)
906 (function-item gnus-thread-sort-by-author)
907 (function-item gnus-thread-sort-by-recipient)
908 (function-item gnus-thread-sort-by-subject)
909 (function-item gnus-thread-sort-by-date)
910 (function-item gnus-thread-sort-by-score)
911 (function-item gnus-thread-sort-by-most-recent-number)
912 (function-item gnus-thread-sort-by-most-recent-date)
913 (function-item gnus-thread-sort-by-random)
914 (function-item gnus-thread-sort-by-total-score)
915 (function :tag "other"))
916 (boolean :tag "Reverse order")))))
917
900(defcustom gnus-thread-score-function '+ 918(defcustom gnus-thread-score-function '+
901 "*Function used for calculating the total score of a thread. 919 "*Function used for calculating the total score of a thread.
902 920
@@ -4854,10 +4872,25 @@ If LINE, insert the rebuilt thread starting on line LINE."
4854 (gnus-delete-line))))))) 4872 (gnus-delete-line)))))))
4855 4873
4856(defun gnus-sort-threads-recursive (threads func) 4874(defun gnus-sort-threads-recursive (threads func)
4875 ;; Responsible for sorting the root articles of threads.
4876 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4877 'gnus-thread-sort-functions)
4878 func
4879 (gnus-make-sort-function
4880 gnus-subthread-sort-functions))))
4881 (sort (mapcar (lambda (thread)
4882 (cons (car thread)
4883 (and (cdr thread)
4884 (gnus-sort-subthreads-recursive
4885 (cdr thread) subthread-sort-func))))
4886 threads) func)))
4887
4888(defun gnus-sort-subthreads-recursive (threads func)
4889 ;; Responsible for sorting subthreads.
4857 (sort (mapcar (lambda (thread) 4890 (sort (mapcar (lambda (thread)
4858 (cons (car thread) 4891 (cons (car thread)
4859 (and (cdr thread) 4892 (and (cdr thread)
4860 (gnus-sort-threads-recursive (cdr thread) func)))) 4893 (gnus-sort-subthreads-recursive (cdr thread) func))))
4861 threads) func)) 4894 threads) func))
4862 4895
4863(defun gnus-sort-threads-loop (threads func) 4896(defun gnus-sort-threads-loop (threads func)
@@ -4885,9 +4918,7 @@ If LINE, insert the rebuilt thread starting on line LINE."
4885 (condition-case nil 4918 (condition-case nil
4886 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)) 4919 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4887 (sort-func (gnus-make-sort-function gnus-thread-sort-functions))) 4920 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4888 (if gnus-sort-threads-recursively 4921 (gnus-sort-threads-recursive threads sort-func))
4889 (gnus-sort-threads-recursive threads sort-func)
4890 (sort threads sort-func)))
4891 ;; Even after binding max-lisp-eval-depth, the recursive 4922 ;; Even after binding max-lisp-eval-depth, the recursive
4892 ;; sorter might fail for very long threads. In that case, 4923 ;; sorter might fail for very long threads. In that case,
4893 ;; try using a (less well-tested) non-recursive sorter. 4924 ;; try using a (less well-tested) non-recursive sorter.