From unknown Thu Jun 19 13:59:28 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#49081 <49081@debbugs.gnu.org> To: bug#49081 <49081@debbugs.gnu.org> Subject: Status: 28.0.50; [PATCH] Feature suggestion, Gnus summary mode sorting for extra headers Reply-To: bug#49081 <49081@debbugs.gnu.org> Date: Thu, 19 Jun 2025 20:59:28 +0000 retitle 49081 28.0.50; [PATCH] Feature suggestion, Gnus summary mode sortin= g for extra headers reassign 49081 emacs submitter 49081 Alex Bochannek severity 49081 normal tag 49081 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 17 19:53:24 2021 Received: (at submit) by debbugs.gnu.org; 17 Jun 2021 23:53:24 +0000 Received: from localhost ([127.0.0.1]:55353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lu1p5-000415-RY for submit@debbugs.gnu.org; Thu, 17 Jun 2021 19:53:24 -0400 Received: from lists.gnu.org ([209.51.188.17]:42452) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lu1p1-00040u-3D for submit@debbugs.gnu.org; Thu, 17 Jun 2021 19:53:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lu1p0-0006nN-DI for bug-gnu-emacs@gnu.org; Thu, 17 Jun 2021 19:53:18 -0400 Received: from ns.lapseofthought.com ([50.0.39.240]:11596 helo=mail.lapseofthought.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lu1ox-0008EB-Uy for bug-gnu-emacs@gnu.org; Thu, 17 Jun 2021 19:53:18 -0400 Received: from awb-mbp.local (unknown [IPv6:2601:646:4200:b470:dd83:77db:45db:bc2e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lapseofthought.com (Postfix) with ESMTPSA id 4G5f546zf0z3pdq3 for ; Thu, 17 Jun 2021 16:53:12 -0700 (PDT) From: Alex Bochannek To: bug-gnu-emacs@gnu.org Subject: 28.0.50; [PATCH] Feature suggestion, Gnus summary mode sorting for extra headers Date: Thu, 17 Jun 2021 16:53:11 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Authentication-Results: ORIGINATING; auth=pass smtp.auth=alex smtp.mailfrom=alex@bochannek.com Received-SPF: pass client-ip=50.0.39.240; envelope-from=alex@bochannek.com; helo=mail.lapseofthought.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain Hello! Since I was able to get the Newsgroups extra header working for `nnvirtual' groups, I would like to not only limit, but also sort by the extra headers. Thanks! New Gnus Summary buffer sort options for extra headers * lisp/gnus/gnus-sum.el (gnus-article-sort-functions) (gnus-thread-sort-functions, gnus-subthread-sort-functions) (gnus-summary-mode-map, gnus-summary-make-menu-bar) (gnus-article-sort-by-newsgroups) (gnus-summary-sort-by-newsgroups, gnus-summary-sort-by-extra): Sort by Newsgroups extra header. Prompt for header name for other extra headers. * doc/misc/gnus.texi (Summary Sorting): Document new sort functions * etc/NEWS: New Gnus Summary buffer sort feature --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index b63947c044..c9b5b2d9ff 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -4126,6 +4126,8 @@ Topic Variables Level. @item g Number of groups in the topic. +@item G +Number of groups in the topic and all its subtopics. @item a Number of unread articles in the topic. @item A @@ -7525,6 +7527,7 @@ Sorting the Summary Buffer @findex gnus-thread-sort-by-author @findex gnus-thread-sort-by-recipient @findex gnus-thread-sort-by-number +@findex gnus-thread-sort-by-newsgroups @findex gnus-thread-sort-by-random @vindex gnus-thread-sort-functions @findex gnus-thread-sort-by-most-recent-number @@ -7542,6 +7545,7 @@ Sorting the Summary Buffer @code{gnus-thread-sort-by-score}, @code{gnus-thread-sort-by-most-recent-number}, @code{gnus-thread-sort-by-most-recent-date}, +@code{gnus-thread-sort-by-newsgroups} and @code{gnus-thread-sort-by-random} and @code{gnus-thread-sort-by-total-score}. @@ -7603,6 +7607,7 @@ Sorting the Summary Buffer @findex gnus-article-sort-by-score @findex gnus-article-sort-by-subject @findex gnus-article-sort-by-author +@findex gnus-article-sort-by-newsgroups @findex gnus-article-sort-by-random @findex gnus-article-sort-by-number @findex gnus-article-sort-by-most-recent-number @@ -7614,8 +7619,8 @@ Sorting the Summary Buffer predicate functions are @code{gnus-article-sort-by-number}, @code{gnus-article-sort-by-author}, @code{gnus-article-sort-by-subject}, @code{gnus-article-sort-by-date}, -@code{gnus-article-sort-by-random}, and -@code{gnus-article-sort-by-score}. +@code{gnus-article-sort-by-newsgroups}, @code{gnus-article-sort-by-random}, +and @code{gnus-article-sort-by-score}. If you want to sort an unthreaded summary display by subject, you could say something like: @@ -10403,6 +10408,17 @@ Summary Sorting @findex gnus-summary-sort-by-score Sort by score (@code{gnus-summary-sort-by-score}). +@item C-c C-s C-u +@kindex C-c C-s C-u @r{(Summary)} +@findex gnus-summary-sort-by-newsgroups +Sort by newsgroups (@code{gnus-summary-sort-by-newsgroups}). + +@item C-c C-s C-x +@kindex C-c C-s C-x @r{(Summary)} +@findex gnus-summary-sort-by-extra +Prompts for extra header to sort by (@code{gnus-summary-sort-by-extra}). +An error will be raised if no sort functions for the header are defined. + @item C-c C-s C-r @kindex C-c C-s C-r @r{(Summary)} @findex gnus-summary-sort-by-random diff --git a/etc/NEWS b/etc/NEWS index da1372baf4..b5c1fa79ff 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -897,6 +897,12 @@ String or list of strings specifying switches for Git log under VC. ** Gnus ++++ +*** New Summary buffer sort options for extra headers. +The extra header sort option ('C-c C-s C-x') prompts for a header +and fails if no sort function has been defined. Sorting by +Newsgroups ('C-c C-s C-u') has been pre-defined. + +++ *** The '#' command in the Group and Summary buffer now toggles, instead of sets, the process mark. diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index bcd76dda29..7c5d3833f1 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -879,8 +879,9 @@ gnus-article-sort-functions Ready-made functions include `gnus-article-sort-by-number', `gnus-article-sort-by-author', `gnus-article-sort-by-subject', -`gnus-article-sort-by-date', `gnus-article-sort-by-random' -and `gnus-article-sort-by-score'. +`gnus-article-sort-by-date', `gnus-article-sort-by-score', +`gnus-article-sort-by-rsv', `gnus-article-sort-by-newsgroups', +and `gnus-article-sort-by-random'. When threading is turned on, the variable `gnus-thread-sort-functions' controls how articles are sorted." @@ -892,6 +893,7 @@ gnus-article-sort-functions (function-item gnus-article-sort-by-date) (function-item gnus-article-sort-by-score) (function-item gnus-article-sort-by-rsv) + (function-item gnus-article-sort-by-newsgroups) (function-item gnus-article-sort-by-random) (function :tag "other")) (boolean :tag "Reverse order")))) @@ -916,8 +918,8 @@ gnus-thread-sort-functions `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient' `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date', `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number', -`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random', -and `gnus-thread-sort-by-total-score' (see +`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-newsgroups', +`gnus-thread-sort-by-random', and `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function'). When threading is turned off, the variable @@ -938,6 +940,7 @@ gnus-thread-sort-functions (function-item gnus-thread-sort-by-rsv) (function-item gnus-thread-sort-by-most-recent-number) (function-item gnus-thread-sort-by-most-recent-date) + (function-item gnus-thread-sort-by-newsgroups) (function-item gnus-thread-sort-by-random) (function-item gnus-thread-sort-by-total-score) (function :tag "other")) @@ -961,6 +964,7 @@ gnus-subthread-sort-functions (function-item gnus-thread-sort-by-score) (function-item gnus-thread-sort-by-most-recent-number) (function-item gnus-thread-sort-by-most-recent-date) + (function-item gnus-thread-sort-by-newsgroups) (function-item gnus-thread-sort-by-random) (function-item gnus-thread-sort-by-total-score) (function :tag "other")) @@ -1976,6 +1980,8 @@ gnus-summary-mode-map "\C-c\C-s\C-i" gnus-summary-sort-by-score "\C-c\C-s\C-o" gnus-summary-sort-by-original "\C-c\C-s\C-r" gnus-summary-sort-by-random + "\C-c\C-s\C-u" gnus-summary-sort-by-newsgroups + "\C-c\C-s\C-x" gnus-summary-sort-by-extra "=" gnus-summary-expand-window "\C-x\C-s" gnus-summary-reselect-current-group "\M-g" gnus-summary-rescan-group @@ -2831,6 +2837,8 @@ gnus-summary-make-menu-bar ["Sort by lines" gnus-summary-sort-by-lines t] ["Sort by characters" gnus-summary-sort-by-chars t] ["Sort by marks" gnus-summary-sort-by-marks t] + ["Sort by newsgroup" gnus-summary-sort-by-newsgroups t] + ["Sort by extra" gnus-summary-sort-by-extra t] ["Randomize" gnus-summary-sort-by-random t] ["Original sort" gnus-summary-sort-by-original t]) ("Help" @@ -5180,6 +5188,24 @@ gnus-thread-sort-by-most-recent-date "Sort threads such that the thread with the most recently dated article comes first." (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2))) +(defun gnus-article-sort-by-newsgroups (h1 h2) + "Sort articles by newsgroups." + (gnus-string< + (let ((extract (funcall + gnus-extract-address-components + (or (cdr (assq 'Newsgroups (mail-header-extra h1))) "")))) + (or (car extract) (cadr extract))) + (let ((extract (funcall + gnus-extract-address-components + (or (cdr (assq 'Newsgroups (mail-header-extra h2))) "")))) + (or (car extract) (cadr extract))))) + +(defun gnus-thread-sort-by-newsgroups (h1 h2) + "Sort threads by root newsgroups." + (gnus-article-sort-by-newsgroups + (gnus-thread-header h1) (gnus-thread-header h2))) + + ; Since this is called not only to sort the top-level threads, but ; also in recursive sorts to order the articles within a thread, each ; article will be processed many times. Thus it speeds things up @@ -12122,6 +12148,12 @@ gnus-summary-sort-by-marks (interactive "P" gnus-summary-mode) (gnus-summary-sort 'marks reverse)) +(defun gnus-summary-sort-by-newsgroups (&optional reverse) + "Sort the summary buffer by newsgroups alphabetically. +Argument REVERSE means reverse order." + (interactive "P" gnus-summary-mode) + (gnus-summary-sort 'newsgroups reverse)) + (defun gnus-summary-sort-by-original (&optional _reverse) "Sort the summary buffer using the default sorting method. Argument REVERSE means reverse order." @@ -12133,6 +12165,24 @@ gnus-summary-sort-by-original ;; Hide subthreads if needed. (gnus-summary-maybe-hide-threads))) +(defun gnus-summary-sort-by-extra (&optional reverse) + "Sort the summary buffer using an extra header. +Argument REVERSE means reverse order." + (interactive "P" gnus-summary-mode) + (let* ((extra-header + (gnus-completing-read "Sort by extra header" + (mapcar #'symbol-name gnus-extra-headers) + t nil nil + (symbol-name + (car gnus-extra-headers)))) + (header (downcase extra-header))) + (if (and (fboundp (intern + (format "gnus-thread-sort-by-%s" header))) + (fboundp + (intern (format "gnus-article-sort-by-%s" header)))) + (gnus-summary-sort header reverse) + (error "No sort function defined for header: %s" extra-header)))) + (defun gnus-summary-sort (predicate reverse) "Sort summary buffer by PREDICATE. REVERSE means reverse order." (let* ((current (gnus-summary-article-number)) --=-=-= Content-Type: text/plain -- Alex. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 19 09:14:27 2021 Received: (at 49081) by debbugs.gnu.org; 19 Jun 2021 13:14:27 +0000 Received: from localhost ([127.0.0.1]:58770 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luanq-00023s-O0 for submit@debbugs.gnu.org; Sat, 19 Jun 2021 09:14:26 -0400 Received: from quimby.gnus.org ([95.216.78.240]:51408) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luano-00023a-8a for 49081@debbugs.gnu.org; Sat, 19 Jun 2021 09:14:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ziMnWqwmf37wQcBLPhb3ucm+OtkmCU6QCISQNLE3WZw=; b=GMpxQ67P4K8iEzLPCZJSWYgxCK lE87GnB/IDxxy4T1U171m4AAn3O8R7vp8VUp8t2oipGbntIKtkqgfO3UI5ZOLeiHZMsv9txb2YXlq PwZIZDVD9s/OmM1xl/NmiSeh35meS2EUlsdEs2WlQA8HacXPmCdqcHJIJEX94teMYXck=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1luang-0002jo-7a; Sat, 19 Jun 2021 15:14:18 +0200 From: Lars Ingebrigtsen To: Alex Bochannek Subject: Re: bug#49081: 28.0.50; [PATCH] Feature suggestion, Gnus summary mode sorting for extra headers References: X-Now-Playing: Oh Sees's _Face Stabber_: =?utf-8?Q?=22Ghol=C3=BC=22?= Date: Sat, 19 Jun 2021 15:14:15 +0200 In-Reply-To: (Alex Bochannek's message of "Thu, 17 Jun 2021 16:53:11 -0700") Message-ID: <875yya0zfc.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Alex Bochannek writes: > Since I was able to get the Newsgroups extra header working for > `nnvirtual' groups, I would like to not only limit, but also sort by the > extra headers. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 49081 Cc: 49081@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Alex Bochannek writes: > Since I was able to get the Newsgroups extra header working for > `nnvirtual' groups, I would like to not only limit, but also sort by the > extra headers. Looks good; applied with one minor tweak: > +(defun gnus-article-sort-by-newsgroups (h1 h2) > + "Sort articles by newsgroups." > + (gnus-string< > + (let ((extract (funcall > + gnus-extract-address-components > + (or (cdr (assq 'Newsgroups (mail-header-extra h1))) "")))) > + (or (car extract) (cadr extract))) > + (let ((extract (funcall > + gnus-extract-address-components > + (or (cdr (assq 'Newsgroups (mail-header-extra h2))) "")))) > + (or (car extract) (cadr extract))))) I rewrote that to: (defun gnus-article-sort-by-newsgroups (h1 h2) "Sort articles by newsgroups." (let ((ex (lambda (h) (let ((extract (funcall gnus-extract-address-components (or (cdr (assq 'Newsgroups (mail-header-extra h))) "")))) (or (car extract) (cadr extract)))))) (gnus-string< (funcall ex h1) (funcall ex h2)))) To avoid the duplication -- let me know if I messed up that bit. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 19 09:14:33 2021 Received: (at control) by debbugs.gnu.org; 19 Jun 2021 13:14:33 +0000 Received: from localhost ([127.0.0.1]:58773 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luanx-000249-0X for submit@debbugs.gnu.org; Sat, 19 Jun 2021 09:14:33 -0400 Received: from quimby.gnus.org ([95.216.78.240]:51422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luanv-00023q-07 for control@debbugs.gnu.org; Sat, 19 Jun 2021 09:14:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0xn5LKws8dlyWdTJyXJD21X9Mm8HFJqM6Z1l7seXfbo=; b=oqwkKjQJ/jEhqvlBLlUxZFx/8m h4CEtzaQ0YvECgd/hMmHEyGcqaiBKYdmdPcNA1jak5Ov49O6CvF15QhwRJ1tG5bJgLnSUff5OHoxC SQjI/AEMGgee89Lz7eamXTfvi4HIV+9tDYavBld7sLmJYUv4NBrneXjJP/GoBe71eAkQ=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1luann-0002k2-LJ for control@debbugs.gnu.org; Sat, 19 Jun 2021 15:14:25 +0200 Date: Sat, 19 Jun 2021 15:14:23 +0200 Message-Id: <874kdu0zf4.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #49081 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 49081 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) close 49081 28.1 quit From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 19 15:09:00 2021 Received: (at 49081) by debbugs.gnu.org; 19 Jun 2021 19:09:00 +0000 Received: from localhost ([127.0.0.1]:60813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lugKy-0005SO-DU for submit@debbugs.gnu.org; Sat, 19 Jun 2021 15:09:00 -0400 Received: from ns.lapseofthought.com ([50.0.39.240]:42708 helo=mail.lapseofthought.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lugKx-0005SG-FL for 49081@debbugs.gnu.org; Sat, 19 Jun 2021 15:09:00 -0400 Received: from awb-mbp.local (unknown [IPv6:2601:646:4200:b470:e50d:205c:630:add7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lapseofthought.com (Postfix) with ESMTPSA id 4G6lh84RlJz3pdpY; Sat, 19 Jun 2021 12:08:56 -0700 (PDT) From: Alex Bochannek To: Lars Ingebrigtsen Subject: Re: bug#49081: 28.0.50; [PATCH] Feature suggestion, Gnus summary mode sorting for extra headers References: <875yya0zfc.fsf@gnus.org> Date: Sat, 19 Jun 2021 12:08:55 -0700 In-Reply-To: <875yya0zfc.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 19 Jun 2021 15:14:15 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Authentication-Results: ORIGINATING; auth=pass smtp.auth=alex smtp.mailfrom=alex@bochannek.com X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 49081 Cc: 49081@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Alex Bochannek writes: > >> Since I was able to get the Newsgroups extra header working for >> `nnvirtual' groups, I would like to not only limit, but also sort by the >> extra headers. > > Looks good; applied with one minor tweak: > >> +(defun gnus-article-sort-by-newsgroups (h1 h2) >> + "Sort articles by newsgroups." >> + (gnus-string< >> + (let ((extract (funcall >> + gnus-extract-address-components >> + (or (cdr (assq 'Newsgroups (mail-header-extra h1))) "")))) >> + (or (car extract) (cadr extract))) >> + (let ((extract (funcall >> + gnus-extract-address-components >> + (or (cdr (assq 'Newsgroups (mail-header-extra h2))) "")))) >> + (or (car extract) (cadr extract))))) > > I rewrote that to: > > (defun gnus-article-sort-by-newsgroups (h1 h2) > "Sort articles by newsgroups." > (let ((ex > (lambda (h) > (let ((extract > (funcall gnus-extract-address-components > (or (cdr (assq 'Newsgroups (mail-header-extra h))) > "")))) > (or (car extract) (cadr extract)))))) > (gnus-string< (funcall ex h1) (funcall ex h2)))) > > To avoid the duplication -- let me know if I messed up that bit. Looks good, thank you! I originally had duplicated that code from `gnus-article-sort-by-recipient' and it's probably a good idea to make that into a utility function. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 908c10c11d..788676c7c8 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -5085,15 +5085,10 @@ gnus-thread-sort-by-author (defsubst gnus-article-sort-by-recipient (h1 h2) "Sort articles by recipient." - (gnus-string< - (let ((extract (funcall - gnus-extract-address-components - (or (cdr (assq 'To (mail-header-extra h1))) "")))) - (or (car extract) (cadr extract))) - (let ((extract (funcall - gnus-extract-address-components - (or (cdr (assq 'To (mail-header-extra h2))) "")))) - (or (car extract) (cadr extract))))) + (let ((ex + (lambda (h) + (gnus-article-sort-extract-extra 'To h)))) + (gnus-string< (funcall ex h1) (funcall ex h2)))) (defun gnus-thread-sort-by-recipient (h1 h2) "Sort threads by root recipient." @@ -5188,15 +5183,11 @@ gnus-thread-sort-by-most-recent-date "Sort threads such that the thread with the most recently dated article comes first." (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2))) -(defun gnus-article-sort-by-newsgroups (h1 h2) +(defsubst gnus-article-sort-by-newsgroups (h1 h2) "Sort articles by newsgroups." (let ((ex - (lambda (h) - (let ((extract - (funcall gnus-extract-address-components - (or (cdr (assq 'Newsgroups (mail-header-extra h))) - "")))) - (or (car extract) (cadr extract)))))) + (lambda (h) + (gnus-article-sort-extract-extra 'Newsgroups h)))) (gnus-string< (funcall ex h1) (funcall ex h2)))) (defun gnus-thread-sort-by-newsgroups (h1 h2) @@ -5204,6 +5195,12 @@ gnus-thread-sort-by-newsgroups (gnus-article-sort-by-newsgroups (gnus-thread-header h1) (gnus-thread-header h2))) +(defsubst gnus-article-sort-extract-extra (Name header) + (let ((extract + (funcall gnus-extract-address-components + (or (cdr (assq name (mail-header-extra header))) + "")))) + (or (car extract) (cadr extract)))) ; Since this is called not only to sort the top-level threads, but ; also in recursive sorts to order the articles within a thread, each --=-=-= Content-Type: text/plain A similar pattern is used by `gnus-article-sort-by-author', but I didn't see an easy way to unify these without also passing around functions by header type. Also, I haven't used `defsubst' before, so I leave it up to you if it makes sense to use that for the `gnus-article-sort-by-newsgroups' and `gnus-article-sort-by-newsgroups', respectively. Thanks! -- Alex. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 21 08:36:29 2021 Received: (at 49081) by debbugs.gnu.org; 21 Jun 2021 12:36:29 +0000 Received: from localhost ([127.0.0.1]:35763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvJAD-0006eF-3w for submit@debbugs.gnu.org; Mon, 21 Jun 2021 08:36:29 -0400 Received: from quimby.gnus.org ([95.216.78.240]:51942) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvJAA-0006dv-6I for 49081@debbugs.gnu.org; Mon, 21 Jun 2021 08:36:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=aj8+ZR6Rz0gjLQOT3KOtc2t4r/TzVBx7LfHglY+a/Oo=; b=LuMgUoiJzIPWGnnfzL0+/BoXhd 9DWIIdHUnMHyYOicJAoKlBv2M3kxEbNdZZSoedWA3e6uoqFeFeNa/s6jxV/0E/v1NAh/hQ4pXbMUB J7WQpG42XLjIlTqSpK7KSEP6NEBfmmMMfxram57lkY0MM+TAvs1HfTODrPgZ5JZglU8E=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lvJA1-0003uj-IM; Mon, 21 Jun 2021 14:36:19 +0200 From: Lars Ingebrigtsen To: Alex Bochannek Subject: Re: bug#49081: 28.0.50; [PATCH] Feature suggestion, Gnus summary mode sorting for extra headers References: <875yya0zfc.fsf@gnus.org> X-Now-Playing: Yes's _Tormato_: "Days (Demo)" Date: Mon, 21 Jun 2021 14:36:17 +0200 In-Reply-To: (Alex Bochannek's message of "Sat, 19 Jun 2021 12:08:55 -0700") Message-ID: <877dintmwu.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Alex Bochannek writes: > I originally had duplicated that code from > `gnus-article-sort-by-recipient' and it's probably a good idea to make > that into a utility function. Thanks; applied (with some whitespace changes). Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 49081 Cc: 49081@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Alex Bochannek writes: > I originally had duplicated that code from > `gnus-article-sort-by-recipient' and it's probably a good idea to make > that into a utility function. Thanks; applied (with some whitespace changes). -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 21 14:22:51 2021 Received: (at 49081) by debbugs.gnu.org; 21 Jun 2021 18:22:51 +0000 Received: from localhost ([127.0.0.1]:36904 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvOZO-00068v-Sj for submit@debbugs.gnu.org; Mon, 21 Jun 2021 14:22:51 -0400 Received: from ns.lapseofthought.com ([50.0.39.240]:5330 helo=mail.lapseofthought.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvOZN-00068n-C0 for 49081@debbugs.gnu.org; Mon, 21 Jun 2021 14:22:50 -0400 Received: from awb-mbp.local (unknown [IPv6:2601:646:4200:b470:e85b:bfc1:2231:95d9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lapseofthought.com (Postfix) with ESMTPSA id 4G7yYz5WK5z3pdX4; Mon, 21 Jun 2021 11:22:47 -0700 (PDT) From: Alex Bochannek To: Lars Ingebrigtsen Subject: Re: bug#49081: 28.0.50; [PATCH] Feature suggestion, Gnus summary mode sorting for extra headers References: <875yya0zfc.fsf@gnus.org> <877dintmwu.fsf@gnus.org> Date: Mon, 21 Jun 2021 11:22:47 -0700 In-Reply-To: <877dintmwu.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 21 Jun 2021 14:36:17 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) MIME-Version: 1.0 Content-Type: text/plain Authentication-Results: ORIGINATING; auth=pass smtp.auth=alex smtp.mailfrom=alex@bochannek.com X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 49081 Cc: 49081@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > Alex Bochannek writes: > >> I originally had duplicated that code from >> `gnus-article-sort-by-recipient' and it's probably a good idea to make >> that into a utility function. > > Thanks; applied (with some whitespace changes). Looks good, thanks! -- Alex. From unknown Thu Jun 19 13:59:28 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 20 Jul 2021 11:24:10 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator