From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/87462 Path: news.gmane.org!.POSTED!not-for-mail From: John Magolske Newsgroups: gmane.emacs.gnus.general Subject: Re: Sort recent threads towards bottom when gathering threads by subject? Date: Fri, 07 Apr 2017 16:47:10 -0700 Message-ID: <87lgrbhjb5.fsf@b79.net> References: <87shngnz0m.fsf@b79.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1491610607 23223 195.159.176.226 (8 Apr 2017 00:16:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Apr 2017 00:16:47 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) To: ding@gnus.org Original-X-From: ding-owner+m35683@lists.math.uh.edu Sat Apr 08 02:16:39 2017 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from mxfilter-048034.atla03.us.yomura.com ([107.189.48.34]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwe3M-0004Tx-US for ding-account@gmane.org; Sat, 08 Apr 2017 02:16:33 +0200 X-Yomura-MXScrub: 1.0 Original-Received: from lists1.math.uh.edu (unknown [129.7.128.208]) by mxfilter-048034.atla03.us.yomura.com (Halon) with ESMTPS id a024bf87-1bf0-11e7-8ed1-b499baa2b07a; Sat, 08 Apr 2017 00:16:35 +0000 (UTC) Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.87) (envelope-from ) id 1cwe2g-0003H4-3B; Fri, 07 Apr 2017 19:15:50 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by lists1.math.uh.edu with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cwe2c-0003GU-HE for ding@lists.math.uh.edu; Fri, 07 Apr 2017 19:15:46 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1.2:DHE-RSA-AES128-SHA:128) (Exim 4.87) (envelope-from ) id 1cwe2Z-0004i8-HW for ding@lists.math.uh.edu; Fri, 07 Apr 2017 19:15:46 -0500 Original-Received: from mail6.webfaction.com ([74.55.86.74] helo=smtp.webfaction.com) by quimby.gnus.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1cwe2X-0001jz-SH for ding@gnus.org; Sat, 08 Apr 2017 02:15:42 +0200 Original-Received: from localhost (142-254-78-28.dsl.dynamic.fusionbroadband.com [142.254.78.28]) by smtp.webfaction.com (Postfix) with ESMTP id 9510C207C384 for ; Fri, 7 Apr 2017 23:45:58 +0000 (UTC) In-Reply-To: <87shngnz0m.fsf@b79.net> (John Magolske's message of "Tue, 14 Feb 2017 15:17:13 -0800") List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:87462 Archived-At: --=-=-= Content-Type: text/plain I found a solution to this in the post "Sorting threads after gathering threads" [1], and some bug reports [2] [3]. I used the patch in [2] against gnus-sum.el, placing the relevant parts into a function that I call from my gnus init file. I've attached the function here, and that along with something like: (load "~/.emacs.d/gnus/gathered-threads-by-subject-sort.el") is the *only* way I've found to get the sorting order I want when gathering threads by subject in Gnus -- sorting the most recent threads towards the bottom with sorting done by the most recent message rather than the root/oldest message of threads. [1] http://emacs.1067599.n8.nabble.com/bug-21462-25-0-50-Gnus-thread-gathering-and-sorting-inverted-td368462.html [2] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=18156 [3] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21462 --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=gathered-threads-by-subject-sort.el Content-Transfer-Encoding: quoted-printable Content-Description: function to sort the most recent threads towards the bottom when gathering threads by subject in Gnus ;; Some functions from gnus-sum.el redefined per ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21462=20 ;; (Gnus thread gathering and sorting inverted) ;; using patch: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21462;msg= =3D5;att=3D1 ;; I've found this necessary when wanting to sort most recent threads towar= ds ;; the bottom when gathering threads by subject. With the stock gnus-sum.el ;; I find threads are ordered towards the bottom with sorting done by the ;; root/oldest message of threads rather than the most recent message. ;; this function was modified (defun gnus-summary-prepare () "Generate the summary buffer." (interactive) (let ((inhibit-read-only t)) (erase-buffer) (setq gnus-newsgroup-data nil gnus-newsgroup-data-reverse nil) (gnus-run-hooks 'gnus-summary-generate-hook) ;; Generate the buffer, either with threads or without. (when gnus-newsgroup-headers (gnus-summary-prepare-threads (if gnus-show-threads (gnus-sort-gathered-threads (gnus-sort-threads (funcall gnus-summary-thread-gathering-function (gnus-cut-threads (gnus-make-threads))))) ;; Unthreaded display. (gnus-sort-articles gnus-newsgroup-headers)))) (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data)) ;; Call hooks for modifying summary buffer. (goto-char (point-min)) (gnus-run-hooks 'gnus-summary-prepare-hook))) ;; this function was added (defun gnus-make-threaded-sort (func) (gnus-byte-compile `(lambda (t1 t2) (,func (if (stringp (car t1)) (cdr t1) t1) (if (stringp (car t2)) (cdr t2) t2))))) ;; this function was modified (defun gnus-sort-threads (threads) "Sort THREADS." (if (not gnus-thread-sort-functions) threads (gnus-message 8 "Sorting threads...") (prog1 (condition-case nil (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)) (sort-func (gnus-make-threaded-sort (gnus-make-sort-function gnus-thread-sort-functions)))) (gnus-sort-threads-recursive 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. (error (gnus-message 9 "Sorting threads with loop...") (gnus-sort-threads-loop threads (gnus-make-sort-function gnus-thread-sort-functions)))) (gnus-message 8 "Sorting threads...done")))) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Regards, John John Magolske writes: >=20 > For a mailing list with no Message-ID References or In-Reply-To headers, > I gather messages with the same subject line together: > > (setq gnus-summary-thread-gathering-function > 'gnus-gather-threads-by-subject) > > And I'd like to have threads sorted so that the most recent individual > message or thread with the most recent message is ordered towards the > bottom. Here's a simplified representation of actual messages in the > group in question (nnimap+imap-mail btw) showing the closest I can get. > All date/time values are from the "Received:" header and in UTC : > > A (2 Feb 13:49) > =E2=94=94=E2=94=80=E2=96=BA A (4 Feb 20:05) > B (2 Feb 18:09) > C (5 Feb 01:19) > > This is not the order of message threads I'm looking for, as message "B" > is positioned more recent than thread "A", even though the most recent > message in thread "A" is more recent than message "B". What I'd like to > have is this: > > B (2 Feb 18:09) > A (2 Feb 13:49) > =E2=94=94=E2=94=80=E2=96=BA A 4 Feb 20:05) > C (5 Feb 01:19) > > But no combination of values for gnus-thread-sort-functions, > gnus-sort-gathered-threads-function, gnus-subthread-sort-functions, etc. > will make this happen. I can get this thread sorting order in groups > that have the appropriate headers to allow gathering threads by > reference with: > > (setq gnus-summary-thread-gathering-function > 'gnus-gather-threads-by-references) > > ...but not when gathering threads by subject. My current settings are: > > (setq gnus-show-threads t) > (setq gnus-fetch-old-headers t) > (setq gnus-thread-ignore-subject t) > (setq-default gnus-summary-make-false-root 'adopt) > (setq-default gnus-summary-make-false-root-always nil) > (setq gnus-sort-gathered-threads-function 'gnus-thread-sort-by-date) > (setq gnus-summary-gather-subject-limit 20) > (setq gnus-summary-thread-gathering-function > 'gnus-gather-threads-by-subject) > (setq gnus-thread-sort-functions > '((not gnus-thread-sort-by-most-recent-number) > (not gnus-thread-sort-by-most-recent-date))) > (setq gnus-subthread-sort-functions > '(gnus-thread-sort-by-number > (gnus-thread-sort-by-most-recent-date))) > (setq gnus-article-sort-functions > '((not gnus-article-sort-by-most-recent-date))) > > By changing gnus-thread-sort-functions to this: > > (setq gnus-thread-sort-functions) > '(gnus-thread-sort-by-most-recent-number) > gnus-thread-sort-by-most-recent-date))) > > I can order threads how I'd like, but most recent messages & threads > with most recent message will be sorted towards the top like so: > > C (5 Feb 01:19) > A (2 Feb 13:49) > =E2=94=94=E2=94=80=E2=96=BA A (4 Feb 20:05) > B (2 Feb 18:09) > > Here thread "A" is ahead of message "B" as the most recent message in > thread "A" is newer than "B". I'd like to have that sorting order, but > towards the bottom, and cannot figure out how to accomplish this. It > seems sorting is being done by the root/oldest message of threads rather > than the most recent message, which leads to the problem of new messages > sometimes being missed as they get pushed back above long threads. The > only solution I can come up with is to sort unthreaded by date towards > the bottom: > > (setq gnus-show-threads nil) > (gnus-summary-sort-by-most-recent-date) > > which displays like so: > > A (2 Feb 13:49) > B (2 Feb 18:09) > A (4 Feb 20:05) > C (5 Feb 01:19) > > But I'd rather have messages gathered by subject. > --=20 John Magolske http://b79.net/contact --=-=-=--