From: Eshel Yaron Date: Mon, 27 May 2024 20:32:30 +0000 (+0200) Subject: Disambiguate imenu completion candidates with text properties X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1c24bde74866473ed9efaa01d4b6190535b46117;p=emacs.git Disambiguate imenu completion candidates with text properties --- diff --git a/lisp/imenu.el b/lisp/imenu.el index 16eeb68c0e1..9a4c15b2da0 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -765,10 +765,12 @@ Return one of the entries in index-alist or nil." nil t nil 'imenu--history-list name))) (when (stringp name) - (setq choice (assoc name prepared-index-alist)) - (if (imenu--subalist-p choice) - (imenu--completion-buffer (cdr choice) prompt) - choice)))) + (or (get-text-property 0 'imenu-choice name) + (progn + (setq choice (assoc name prepared-index-alist)) + (if (imenu--subalist-p choice) + (imenu--completion-buffer (cdr choice) prompt) + choice)))))) (defun imenu--mouse-menu (index-alist event &optional title) "Let the user select from a buffer index from a mouse menu. @@ -798,7 +800,9 @@ Returns t for rescan and otherwise an element or subelement of INDEX-ALIST." (new-prefix (and concat-names (if prefix (concat prefix imenu-level-separator name) - name)))) + (if (eq imenu-flatten 'annotation) + (propertize name 'imenu-choice item) + name))))) (cond ((not (imenu--subalist-p item)) (list (cons (if (and (eq imenu-flatten 'annotation) prefix)