From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 70846@debbugs.gnu.org
Subject: bug#70846: Imenu flatten
Date: Tue, 14 May 2024 09:05:09 +0300 [thread overview]
Message-ID: <86v83hq71e.fsf@mail.linkov.net> (raw)
In-Reply-To: <86r0e6xig7.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 13 May 2024 10:46:32 +0300")
[-- Attachment #1: Type: text/plain, Size: 930 bytes --]
>> 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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: imenu-completion-sort.patch --]
[-- Type: text/x-diff, Size: 1825 bytes --]
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
next prev parent reply other threads:[~2024-05-14 6:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-09 16:29 bug#70846: Imenu flatten Juri Linkov
2024-05-09 16:45 ` Eli Zaretskii
2024-05-10 6:52 ` Juri Linkov
2024-05-10 7:29 ` Eli Zaretskii
2024-05-10 16:45 ` Juri Linkov
2024-05-11 10:33 ` Eli Zaretskii
2024-05-12 6:55 ` Juri Linkov
2024-05-12 7:10 ` Eli Zaretskii
2024-05-12 16:37 ` Juri Linkov
2024-05-12 17:17 ` Eli Zaretskii
2024-05-13 6:57 ` Juri Linkov
2024-05-13 7:46 ` Eli Zaretskii
2024-05-14 6:05 ` Juri Linkov [this message]
2024-05-14 6:34 ` Eli Zaretskii
2024-05-10 17:06 ` Juri Linkov
2024-05-28 17:53 ` Juri Linkov
2024-05-29 18:05 ` Juri Linkov
2024-06-06 5:35 ` Yuan Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86v83hq71e.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=70846@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.