diff options
| author | Eli Zaretskii | 2024-05-29 21:43:57 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2024-05-29 21:43:57 +0300 |
| commit | 98149ad31ea2cfd5a82f95443affd665c9da667b (patch) | |
| tree | 597cb187b4b5c447ee32f6c46e0658edfc88eb54 | |
| parent | f469ab73a777c9930582af8b4fd22967f07808aa (diff) | |
| download | emacs-98149ad31ea2cfd5a82f95443affd665c9da667b.tar.gz emacs-98149ad31ea2cfd5a82f95443affd665c9da667b.zip | |
; 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)
| -rw-r--r-- | doc/emacs/programs.texi | 41 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/imenu.el | 28 |
3 files changed, 50 insertions, 23 deletions
diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index 8ab5033795d..b944d24d91f 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi | |||
| @@ -331,20 +331,43 @@ a negative argument moves back to the start of a sentence. | |||
| 331 | @cindex index of buffer definitions | 331 | @cindex index of buffer definitions |
| 332 | @cindex buffer definitions index | 332 | @cindex buffer definitions index |
| 333 | 333 | ||
| 334 | The Imenu facility offers a way to find the major definitions in | 334 | The Imenu facility offers a way to find the major definitions in a |
| 335 | a file by name. It is also useful in text formatter major modes, | 335 | file by name. It is useful both in programming-language major modes, |
| 336 | where it treats each chapter, section, etc., as a definition. | 336 | where the definitions are variables, functions, etc., and in text |
| 337 | (@xref{Xref}, for a more powerful feature that handles multiple files | 337 | formatter major modes, where it treats each chapter, section, etc., as a |
| 338 | together.) | 338 | definition. (@xref{Xref}, for a more powerful feature that handles |
| 339 | multiple files together.) | ||
| 339 | 340 | ||
| 340 | @findex imenu | 341 | @findex imenu |
| 341 | @vindex imenu-flatten | 342 | @vindex imenu-flatten |
| 342 | If you type @kbd{M-g i} (@code{imenu}), it reads the name of a | 343 | If you type @kbd{M-g i} (@code{imenu}), it reads the name of a |
| 343 | definition using the minibuffer, then moves point to that definition. | 344 | definition using the minibuffer, then moves point to that definition. |
| 344 | You can use completion to specify the name; the command always | 345 | You can use completion to specify the name; the command displays the |
| 345 | displays the whole list of valid names. If you set @code{imenu-flatten} | 346 | list of matching valid names in the completions buffer. If the index is |
| 346 | to a non-@code{nil} value, then instead of the nested menu | 347 | hierarchical, then by default the completion candidates are also shown |
| 347 | you can select a completion candidate from the flat list. | 348 | hierarchically, as a nested list: first you need to choose a section, |
| 349 | then a subsection, etc., and finally the name of the definition. | ||
| 350 | However, if you set @code{imenu-flatten} to a non-@code{nil} value, then | ||
| 351 | instead of the nested menu you can select a completion candidate from a | ||
| 352 | flattened list of definitions. How the sections and subsections are | ||
| 353 | shown in the flattened list of completion candidates depends on the | ||
| 354 | value of @code{imenu-flatten}, which can be one of the following: | ||
| 355 | |||
| 356 | @table @code | ||
| 357 | @vindex imenu-level-separator | ||
| 358 | @item prefix | ||
| 359 | This shows each candidate prefixed by names of its section, subsection, | ||
| 360 | subsubsection, etc., with each level separated from the next by the | ||
| 361 | string that is the value of @code{imenu-level-separator}, by default | ||
| 362 | @samp{:}. | ||
| 363 | |||
| 364 | @item annotation | ||
| 365 | This shows the section names as annotations, following each definition | ||
| 366 | name. | ||
| 367 | |||
| 368 | @item group | ||
| 369 | This shows the completion candidates grouped by their sections. | ||
| 370 | @end table | ||
| 348 | 371 | ||
| 349 | @findex imenu-add-menubar-index | 372 | @findex imenu-add-menubar-index |
| 350 | Alternatively, you can bind the command @code{imenu} to a mouse | 373 | Alternatively, you can bind the command @code{imenu} to a mouse |
| @@ -1059,8 +1059,8 @@ point is not in a comment or a string. It is by default bound to | |||
| 1059 | 1059 | ||
| 1060 | +++ | 1060 | +++ |
| 1061 | *** New user option 'imenu-flatten'. | 1061 | *** New user option 'imenu-flatten'. |
| 1062 | It defines whether to flatten the list of sections in an imenu | 1062 | It controls whether to flatten the list of sections in an imenu, and |
| 1063 | or show it nested. | 1063 | how to display the sections in the flattened list. |
| 1064 | 1064 | ||
| 1065 | +++ | 1065 | +++ |
| 1066 | *** The sort order of Imenu completions can now be customized. | 1066 | *** The sort order of Imenu completions can now be customized. |
diff --git a/lisp/imenu.el b/lisp/imenu.el index 3aec32fa708..708a39a0f71 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el | |||
| @@ -151,18 +151,22 @@ Used for flattening nested indexes with name concatenation." | |||
| 151 | (defcustom imenu-flatten nil | 151 | (defcustom imenu-flatten nil |
| 152 | "Whether to flatten the list of sections in an imenu or show it nested. | 152 | "Whether to flatten the list of sections in an imenu or show it nested. |
| 153 | If nil, use nested indexes. | 153 | If nil, use nested indexes. |
| 154 | If `prefix', pop up the completion buffer with a flattened menu | 154 | If the value is `prefix', pop up the completion buffer with a |
| 155 | where section names are used as a prefix. | 155 | flattened menu where section names are prepended to completion |
| 156 | If `annotation', use completion annotation as a suffix | 156 | candidates as prefixes. |
| 157 | to append section names after the index names. | 157 | If the value is `annotation', annotate each completion candidate |
| 158 | If `group', split completions into groups. | 158 | with a suffix that is the section name to which it belongs. |
| 159 | 159 | If the value is `group', split completion candidates into groups | |
| 160 | The string from `imenu-level-separator' is used to separate names of | 160 | according to the sections. |
| 161 | nested levels while flattening nested indexes with name concatenation." | 161 | Any other value is treated as `prefix'. |
| 162 | :type '(choice (const :tag "Nested" nil) | 162 | |
| 163 | (const :tag "By prefix" prefix) | 163 | The value of `imenu-level-separator', a string, is used to separate |
| 164 | (const :tag "By annotation" annotation) | 164 | names from different flattened levels, such as section names, from the |
| 165 | (const :tag "By group" group)) | 165 | names of completion candidates." |
| 166 | :type '(choice (const :tag "Show nested list" nil) | ||
| 167 | (const :tag "Flat list with sections as prefix" prefix) | ||
| 168 | (const :tag "Flat list annotated with sections" annotation) | ||
| 169 | (const :tag "Flat list grouped by sections" group)) | ||
| 166 | :version "30.1") | 170 | :version "30.1") |
| 167 | 171 | ||
| 168 | (defcustom imenu-generic-skip-comments-and-strings t | 172 | (defcustom imenu-generic-skip-comments-and-strings t |