Function: smart-lisp-find-tag

smart-lisp-find-tag is an interactive and byte-compiled function defined in hmouse-tag.el.

Signature

(smart-lisp-find-tag &optional TAG SHOW-DOC)

Documentation

Find the definition of optional Lisp TAG or show its documentation.

Use identifier at point when TAG is nil. With optional prefix arg SHOW-DOC non-nil, show its documentation. Use hpath:display-buffer to show definition or documentation.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hmouse-tag.el
(defun smart-lisp-find-tag (&optional tag show-doc)
  "Find the definition of optional Lisp TAG or show its documentation.
Use identifier at point when TAG is nil.  With optional prefix
arg SHOW-DOC non-nil, show its documentation.
Use `hpath:display-buffer' to show definition or documentation."
  (interactive
   (list (read-string (format "%s Lisp identifier: "
			      (if current-prefix-arg
				  "Show doc for" "Find")))
	 current-prefix-arg))
  (when (and tag (symbolp tag))
    (setq tag (symbol-name tag)))
  (unless (stringp tag)
    (setq tag (if (stringp hkey-value) hkey-value (smart-lisp-at-tag-p t))))
  (let* ((elisp-flag (smart-emacs-lisp-mode-p))
	 (tag-sym (intern-soft tag)))
    (cond ((and show-doc elisp-flag)
	   ;; Emacs Lisp function, variable and face documentation display.
	   (cond ((fboundp tag-sym) (describe-function tag-sym))
		 ((and tag-sym (boundp tag-sym)) (describe-variable tag-sym))
		 ((facep tag-sym) (describe-face tag-sym))
		 (tag-sym
		  ;; Handles ert test definitions, as one example.
		  (describe-symbol tag-sym))
		 ;; Ignore unbound symbols if displaying doc.
		 (t nil)))

	  ((and elisp-flag
		(let ((result (smart-lisp-bound-symbol-def tag-sym)))
		  (when (and (cdr result)
			     (hpath:display-buffer (car result)))
		    (widen)
		    (goto-char (cdr result))
		    t))))

	  ;; If elisp-flag is true and tag-sym is a bound ert test
	  ;; symbol, then make xref use tags tables rather than its
	  ;; elisp backend since that does not support ert test
	  ;; symbols.  Otherwise, use standard xref backends for the
	  ;; current language.
	  (t (let ((etags-mode (and elisp-flag
				    (fboundp 'ert-test-boundp)
				    (ert-test-boundp tag-sym)
				    (boundp 'xref-etags-mode)
				    xref-etags-mode)))
	       (unwind-protect
		   (progn
		     (and (not etags-mode) elisp-flag (fboundp 'xref-etags-mode)
			  (xref-etags-mode 1))
		     (condition-case ()
			 ;; Tag of any language
			 (when (featurep 'etags)
			   (smart-tags-display tag show-doc)
			   t)
		       (error (unless (and elisp-flag (stringp smart-emacs-tags-file)
					   (condition-case ()
					       (progn (smart-tags-display
						       tag show-doc (list smart-emacs-tags-file))
						      t)
					     (error nil)))
				(error "(smart-lisp): No definition found for `%s'" tag)))))
		 (and (not etags-mode) elisp-flag (fboundp 'xref-etags-mode)
		      (xref-etags-mode 0))))))))