]> git.eshelyaron.com Git - emacs.git/commitdiff
Disambiguate imenu completion candidates with text properties
authorEshel Yaron <me@eshelyaron.com>
Mon, 27 May 2024 20:32:30 +0000 (22:32 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 27 May 2024 20:32:30 +0000 (22:32 +0200)
lisp/imenu.el

index 16eeb68c0e1912129944db9d291182d5b1dcda99..9a4c15b2da0d9dbb68ffbae380189405379daa1c 100644 (file)
@@ -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)