From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#70846: Imenu flatten Date: Tue, 14 May 2024 09:05:09 +0300 Organization: LINKOV.NET Message-ID: <86v83hq71e.fsf@mail.linkov.net> References: <861q6b7xus.fsf@mail.linkov.net> <86le4j53y9.fsf@gnu.org> <86ttj6nopi.fsf@mail.linkov.net> <86v83m3z0v.fsf@gnu.org> <86o79dmx8u.fsf@mail.linkov.net> <8634qo3ag0.fsf@gnu.org> <86o79bzfh1.fsf@mail.linkov.net> <865xvj1p56.fsf@gnu.org> <86cyprx9z9.fsf@mail.linkov.net> <86a5kvymof.fsf@gnu.org> <86frumtd08.fsf@mail.linkov.net> <86r0e6xig7.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38501"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 70846@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 14 08:09:25 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s6lLp-0009s2-1n for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 May 2024 08:09:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s6lLT-0002Gr-JC; Tue, 14 May 2024 02:09:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s6lLR-0002Ct-TS for bug-gnu-emacs@gnu.org; Tue, 14 May 2024 02:09:01 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6lLR-0001Cr-Ij for bug-gnu-emacs@gnu.org; Tue, 14 May 2024 02:09:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s6lLS-0008WM-4a for bug-gnu-emacs@gnu.org; Tue, 14 May 2024 02:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 May 2024 06:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70846 X-GNU-PR-Package: emacs Original-Received: via spool by 70846-submit@debbugs.gnu.org id=B70846.171566691732675 (code B ref 70846); Tue, 14 May 2024 06:09:02 +0000 Original-Received: (at 70846) by debbugs.gnu.org; 14 May 2024 06:08:37 +0000 Original-Received: from localhost ([127.0.0.1]:37260 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s6lL2-0008Ux-Hm for submit@debbugs.gnu.org; Tue, 14 May 2024 02:08:36 -0400 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:60543) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s6lL0-0008UX-0G for 70846@debbugs.gnu.org; Tue, 14 May 2024 02:08:35 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id CEF1D20009; Tue, 14 May 2024 06:08:26 +0000 (UTC) In-Reply-To: <86r0e6xig7.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 13 May 2024 10:46:32 +0300") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:284992 Archived-At: --=-=-= Content-Type: text/plain >> Ok, I could add display-sort-function directly to the imenu completing-read >> that will depend on the value of display-sort-function. Then there will be >> no need to change the manual. > > Except we should then remove the reference to "menus", right? Because > if you do that, the customization of sorting order will affect both > the menus and the completion, right? Indeed, this will require removing the reference to the mouse menus. But when I tried to use imenu-sort-function for sorting the completions, I found a problem that makes such change impossible. The problem is that the default value of imenu-sort-function is nil. This means that by default the items on the mouse menu are unsorted. But the completions are sorted, and we can't change this default behavior. Therefore, imenu-sort-function can't define how the completions are sorted. So this is just a documentation task that is done in this patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=imenu-completion-sort.patch diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index 01a1462044c..8ab5033795d 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -378,6 +378,10 @@ Imenu symbol @code{imenu--sort-by-name} as the value. You can also define your own comparison function by writing Lisp code. + You can also customize how Imenu completions are sorted by changing +the variable @code{completion-category-overrides} and setting its +@code{display-sort-function} for the category @code{imenu}. + If Eglot is activated for the current buffer's project (@pxref{Projects}) and the current buffer's major mode, Eglot provides its own facility for producing the buffer's index based on the diff --git a/etc/NEWS b/etc/NEWS index 8a2c8950fd8..19564062d9f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1046,6 +1046,11 @@ point is not in a comment or a string. It is by default bound to It defines whether to flatten the list of sections in an imenu or show it nested. ++++ +*** Imenu completions now can be sorted. +You can customize the option 'completion-category-overrides' +and set 'display-sort-function' for the category 'imenu'. + ** Which Function mode +++ diff --git a/lisp/imenu.el b/lisp/imenu.el index 93a544ff550..f255dcc7148 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -115,7 +115,10 @@ imenu-after-jump-hook (defcustom imenu-sort-function nil "The function to use for sorting the index mouse-menu. -Affects only the mouse index menu. +Affects only the mouse index menu. If you want to change +the sorting order of completions, you can customize +the option `completion-category-overrides' and set +`display-sort-function' for the category `imenu'. Set this to nil if you don't want any sorting (faster). The items in the menu are then presented in the order they were found --=-=-=--