Support customization of sorting order for Imenu completion candidates

* lisp/imenu.el (imenu--completion-buffer):
Set completion-extra-properties to '(:category imenu).
(imenu--flatten-index-alist): Use imenu--subalist-p to handle
newer format (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...)
as well (bug#70846).

* doc/emacs/misc.texi (DocView Navigation): Fix typo.
This commit is contained in:
Juri Linkov 2024-05-10 19:45:21 +03:00
parent ffc70962ca
commit 5d8c2bad21
2 changed files with 8 additions and 6 deletions

View file

@ -590,7 +590,7 @@ even when @command{mutool} can be found on your system, customize the
variable @code{doc-view-imenu-enabled} to the @code{nil} value. You
can further customize how @code{imenu} items are formatted and
displayed using the variables @code{doc-view-imenu-format} and
@code{doc-view-flatten}.
@code{doc-view-imenu-flatten}.
@node DocView Searching
@subsection DocView Searching

View file

@ -740,10 +740,12 @@ Return one of the entries in index-alist or nil."
(imenu--in-alist name prepared-index-alist)
;; Default to `name' if it's in the alist.
name))))
(let ((minibuffer-setup-hook minibuffer-setup-hook))
;; Display the completion buffer.
(if (not imenu-eager-completion-buffer)
(add-hook 'minibuffer-setup-hook 'minibuffer-completion-help))
;; Display the completion buffer.
(minibuffer-with-setup-hook
(lambda ()
(setq-local completion-extra-properties '(:category imenu))
(unless imenu-eager-completion-buffer
(minibuffer-completion-help)))
(setq name (completing-read prompt
prepared-index-alist
nil t nil 'imenu--history-list name)))
@ -784,7 +786,7 @@ Returns t for rescan and otherwise an element or subelement of INDEX-ALIST."
(concat prefix imenu-level-separator name)
name))))
(cond
((or (markerp pos) (numberp pos))
((not (imenu--subalist-p item))
(list (cons new-prefix pos)))
(t
(imenu--flatten-index-alist pos concat-names new-prefix)))))