; Improve documentation of new Imenu features

* doc/emacs/programs.texi (Imenu): Update documentation of
'imenu-flatten'.

* etc/NEWS: Fix wording of 'imenu-flatten's entry.

* lisp/imenu.el (imenu-flatten): Fix doc string and value
descriptions.  (Bug#70846)
This commit is contained in:
Eli Zaretskii 2024-05-29 21:43:57 +03:00
parent f469ab73a7
commit 98149ad31e
3 changed files with 49 additions and 22 deletions

View file

@ -331,20 +331,43 @@ a negative argument moves back to the start of a sentence.
@cindex index of buffer definitions
@cindex buffer definitions index
The Imenu facility offers a way to find the major definitions in
a file by name. It is also useful in text formatter major modes,
where it treats each chapter, section, etc., as a definition.
(@xref{Xref}, for a more powerful feature that handles multiple files
together.)
The Imenu facility offers a way to find the major definitions in a
file by name. It is useful both in programming-language major modes,
where the definitions are variables, functions, etc., and in text
formatter major modes, where it treats each chapter, section, etc., as a
definition. (@xref{Xref}, for a more powerful feature that handles
multiple files together.)
@findex imenu
@vindex imenu-flatten
If you type @kbd{M-g i} (@code{imenu}), it reads the name of a
definition using the minibuffer, then moves point to that definition.
You can use completion to specify the name; the command always
displays the whole list of valid names. If you set @code{imenu-flatten}
to a non-@code{nil} value, then instead of the nested menu
you can select a completion candidate from the flat list.
You can use completion to specify the name; the command displays the
list of matching valid names in the completions buffer. If the index is
hierarchical, then by default the completion candidates are also shown
hierarchically, as a nested list: first you need to choose a section,
then a subsection, etc., and finally the name of the definition.
However, if you set @code{imenu-flatten} to a non-@code{nil} value, then
instead of the nested menu you can select a completion candidate from a
flattened list of definitions. How the sections and subsections are
shown in the flattened list of completion candidates depends on the
value of @code{imenu-flatten}, which can be one of the following:
@table @code
@vindex imenu-level-separator
@item prefix
This shows each candidate prefixed by names of its section, subsection,
subsubsection, etc., with each level separated from the next by the
string that is the value of @code{imenu-level-separator}, by default
@samp{:}.
@item annotation
This shows the section names as annotations, following each definition
name.
@item group
This shows the completion candidates grouped by their sections.
@end table
@findex imenu-add-menubar-index
Alternatively, you can bind the command @code{imenu} to a mouse

View file

@ -1059,8 +1059,8 @@ point is not in a comment or a string. It is by default bound to
+++
*** New user option 'imenu-flatten'.
It defines whether to flatten the list of sections in an imenu
or show it nested.
It controls whether to flatten the list of sections in an imenu, and
how to display the sections in the flattened list.
+++
*** The sort order of Imenu completions can now be customized.

View file

@ -151,18 +151,22 @@ Used for flattening nested indexes with name concatenation."
(defcustom imenu-flatten nil
"Whether to flatten the list of sections in an imenu or show it nested.
If nil, use nested indexes.
If `prefix', pop up the completion buffer with a flattened menu
where section names are used as a prefix.
If `annotation', use completion annotation as a suffix
to append section names after the index names.
If `group', split completions into groups.
If the value is `prefix', pop up the completion buffer with a
flattened menu where section names are prepended to completion
candidates as prefixes.
If the value is `annotation', annotate each completion candidate
with a suffix that is the section name to which it belongs.
If the value is `group', split completion candidates into groups
according to the sections.
Any other value is treated as `prefix'.
The string from `imenu-level-separator' is used to separate names of
nested levels while flattening nested indexes with name concatenation."
:type '(choice (const :tag "Nested" nil)
(const :tag "By prefix" prefix)
(const :tag "By annotation" annotation)
(const :tag "By group" group))
The value of `imenu-level-separator', a string, is used to separate
names from different flattened levels, such as section names, from the
names of completion candidates."
:type '(choice (const :tag "Show nested list" nil)
(const :tag "Flat list with sections as prefix" prefix)
(const :tag "Flat list annotated with sections" annotation)
(const :tag "Flat list grouped by sections" group))
:version "30.1")
(defcustom imenu-generic-skip-comments-and-strings t