Function: smart-imenu-item-p

smart-imenu-item-p is a byte-compiled function defined in hui-mouse.el.

Signature

(smart-imenu-item-p INDEX-KEY &optional VARIABLE-FLAG NO-RECURSE-FLAG)

Documentation

Return the definition marker pos for INDEX-KEY in current buffer's imenu.

Return nil if INDEX-KEY is not in the imenu. If INDEX-KEY is both a function and a variable, the function definition is used by default; in such a case, when optional VARIABLE-FLAG is non-nil, the variable definition is used instead. NO-RECURSE-FLAG non-nil prevents infinite recursions.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui-mouse.el
;; Derived from `imenu' function in the imenu library.
(defun smart-imenu-item-p (index-key &optional variable-flag no-recurse-flag)
  "Return the definition marker pos for INDEX-KEY in current buffer's imenu.
Return nil if INDEX-KEY is not in the imenu.  If INDEX-KEY is
both a function and a variable, the function definition is used
by default; in such a case, when optional VARIABLE-FLAG is
non-nil, the variable definition is used instead.
NO-RECURSE-FLAG non-nil prevents infinite recursions."
  (when (stringp index-key)
    (let (index-item
	  index-position)
      ;; Convert a string to an alist element.
      (if variable-flag
	  ;; Match to variable definitions only.
	  (setq index-item (assoc index-key
				  (cdr (assoc "Variables" (imenu--make-index-alist)))))
	;; First try to match a function definition and if that fails,
	;; then allow variable definitions and other types of matches as well.
	(let ((alist (imenu--make-index-alist)))
	  (setq index-item (or (assoc index-key alist)
			       ;; Does nothing unless the dash Emacs Lisp
			       ;; library is available for the -flatten function.
			       (and (require 'dash nil t)
                                    (progn
                                      (declare-function -flatten "ext:dash")
				      (assoc index-key (-flatten alist))))))))
      (when index-item
	(setq index-position (when (markerp (cdr index-item))
			       (marker-position (cdr index-item))))
	(if (memq index-position '(1 -99))
	    ;; If index position is 1 or -99, this means the index markers have
	    ;; become out of date after buffer edits (likely imenu-auto-rescan
	    ;; is nil), so do a single rescan to try to fix this.
	    (unless no-recurse-flag
	      (setq imenu--index-alist nil)
	      (imenu--make-index-alist t)
	      (smart-imenu-item-p index-key variable-flag t))
	  index-position)))))