Function: treemacs--goto-tag
treemacs--goto-tag is an autoloaded and byte-compiled function defined
in treemacs-tags.el.
Signature
(treemacs--goto-tag BTN)
Documentation
Go to the tag at BTN.
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-tags.el
;;;###autoload
(defun treemacs--goto-tag (btn)
"Go to the tag at BTN."
;; The only code currently calling this is run through `treemacs--execute-button-action' which always
;; switches windows before running it, so we need to be really careful here when querying any button
;; properties.
(let* ((tag-buffer) (tag-pos))
(treemacs-with-button-buffer btn
(-let [info (treemacs--extract-position
(treemacs-button-get btn :marker)
(car (treemacs-button-get btn :path)))]
(setf tag-buffer (car info)
tag-pos (cdr info))))
(if (not (buffer-live-p tag-buffer))
(pcase treemacs-goto-tag-strategy
('refetch-index
(treemacs--call-imenu-and-goto-tag
(treemacs-safe-button-get btn :path)))
('call-xref
(xref-find-definitions
(treemacs-with-button-buffer btn
(treemacs--get-label-of btn))))
('issue-warning
(treemacs-pulse-on-failure
"Tag '%s' is located in a buffer that does not exist."
(propertize (treemacs-with-button-buffer btn (treemacs--get-label-of btn)) 'face 'treemacs-tags-face)))
(_ (error "[Treemacs] '%s' is an invalid value for treemacs-goto-tag-strategy" treemacs-goto-tag-strategy)))
(progn
(switch-to-buffer tag-buffer nil t)
;; special case for pdf mode buffers - their imenu tags do not store a marker
;; movement must happen via a special callback
(cond
((numberp tag-pos)
(goto-char tag-pos))
((functionp tag-pos)
(funcall tag-pos)))
;; a little bit of convenience - reveal those nested headlines
(when (and (eq major-mode 'org-mode) (fboundp 'org-reveal))
(org-reveal))))))