Variable: imenu-flatten

imenu-flatten is a customizable variable defined in imenu.el.gz.

Value

nil

Documentation

Whether to flatten the list of sections in an imenu or show it nested.

If nil, use nested indexes. 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.

Since the values annotation and group rely on text properties, you can use them only by selecting candidates from the completions buffer, not by typing in the minibuffer. This also means that if you use minibuffer-next-completion (M-<down>) to select a completion while point stays in the minibuffer, you need to customize minibuffer-completion-auto-choose to nil that doesn't insert completion candidates to the minibuffer. Also note that for using the value group you need to customize completions-group to the value t, and completions-format to the value vertical.

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.

This variable was added, or its default value changed, in Emacs 30.1.

View in manual

Probably introduced at or before Emacs version 30.1.

Source Code

;; Defined in /usr/src/emacs/lisp/imenu.el.gz
(defcustom imenu-flatten nil
  "Whether to flatten the list of sections in an imenu or show it nested.
If nil, use nested indexes.
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'.

Since the values `annotation' and `group' rely on text properties,
you can use them only by selecting candidates from the completions
buffer, not by typing in the minibuffer.  This also means that
if you use `minibuffer-next-completion' (`M-<down>') to select
a completion while point stays in the minibuffer, you need
to customize `minibuffer-completion-auto-choose' to nil that
doesn't insert completion candidates to the minibuffer.
Also note that for using the value `group' you need to customize
`completions-group' to the value t, and `completions-format'
to the value `vertical'.

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")