(widen))
(goto-char position))
+(defun imenu-minibuffer-action (string)
+ (let ((choice (or
+ ;; FIXME: `completion--replace' leaves stale
+ ;; `imenu-choice' property on parts of input that it
+ ;; keeps unchagned, so we can't use the next line ATM.
+ ;; (get-text-property 0 'imenu-choice string)
+ (assoc string minibuffer-completion-table))))
+ (when (or (imenu--subalist-p choice) (equal choice imenu--rescan-item))
+ (user-error "`%s' is not associated with a specific position" string))
+ (with-selected-window (minibuffer-selected-window)
+ (push-mark nil t)
+ (pcase choice
+ (`(,name ,pos ,fn . ,args) (apply fn name pos args))
+ (`(,name . ,pos) (funcall imenu-default-goto-function name pos)))
+ (run-hooks 'imenu-after-jump-hook))))
+
;;;###autoload
(defun imenu (index-item)
"Jump to a place in the buffer chosen using a buffer menu or mouse menu.
(`(,name . ,pos) (imenu (list name pos imenu-default-goto-function)))
(_ (error "Unknown imenu item: %S" index-item)))))
+(put 'imenu 'minibuffer-action '(imenu-minibuffer-action . "imenu"))
+
(defun imenu-flush-cache ()
"Flush the current imenu cache.
This forces a full rescan of the buffer to recreate the index alist