From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: Sorting with threads in Gnus Date: Fri, 26 Jul 2013 15:26:38 +0200 Message-ID: <87li4twiy9.fsf@thinkpad.tsdh.org> References: <87d2q8qy0h.fsf@ericabrahamsen.net> <87vc40drow.fsf@thinkpad.tsdh.org> <871u6mlyx5.fsf@ericabrahamsen.net> <87iozxq3ca.fsf@thinkpad.tsdh.org> <87d2q5lmo3.fsf@ericabrahamsen.net> <87ppu5wjw8.fsf@thinkpad.tsdh.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1374845230 24384 80.91.229.3 (26 Jul 2013 13:27:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 26 Jul 2013 13:27:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 26 15:27:12 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V2i33-0002qx-Q8 for geh-help-gnu-emacs@m.gmane.org; Fri, 26 Jul 2013 15:27:09 +0200 Original-Received: from localhost ([::1]:53700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2i33-0006uO-E3 for geh-help-gnu-emacs@m.gmane.org; Fri, 26 Jul 2013 09:27:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2i2p-0006pi-D5 for help-gnu-emacs@gnu.org; Fri, 26 Jul 2013 09:26:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2i2m-00029L-9l for help-gnu-emacs@gnu.org; Fri, 26 Jul 2013 09:26:55 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:38669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2i2m-000295-2G for help-gnu-emacs@gnu.org; Fri, 26 Jul 2013 09:26:52 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V2i2k-0002VY-K8 for help-gnu-emacs@gnu.org; Fri, 26 Jul 2013 15:26:50 +0200 Original-Received: from 91-67-164-26-dynip.superkabel.de ([91.67.164.26]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 26 Jul 2013 15:26:50 +0200 Original-Received: from tsdh by 91-67-164-26-dynip.superkabel.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 26 Jul 2013 15:26:50 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 55 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 91-67-164-26-dynip.superkabel.de User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:UgxJ2mWMimXdqACfwNxJr2DWY1c= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92443 Archived-At: 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 want. --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 LINE." (gnus-message 8 "Sorting threads...") (prog1 (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 gnus-thread-sort-functions))) + (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. Bye, Tassilo