Function: treemacs--extract-position
treemacs--extract-position is a byte-compiled function defined in
treemacs-tags.el.
Signature
(treemacs--extract-position ITEM FILE)
Documentation
Extract a tag's position stored in ITEM and FILE.
The position can be stored in the following ways:
* ITEM is a marker pointing to a tag provided by imenu.
* ITEM is an overlay pointing to a tag provided by imenu with semantic mode.
* ITEM is a raw number pointing to a buffer position.
* ITEM is a cons: special case for imenu elements of an org-mode buffer.
ITEM is an imenu sub-tree and the position is stored as a marker in the first
element's 'org-imenu-marker text property.
* ITEM is a cons: special case for imenu elements of an pdfview-mode buffer.
In this case no position is stored directly, navigation to the tag must happen
via callback
FILE is the path the tag is in, so far it is only relevant for pdfview-mode
tags.
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-tags.el
(defun treemacs--extract-position (item file)
"Extract a tag's position stored in ITEM and FILE.
The position can be stored in the following ways:
* ITEM is a marker pointing to a tag provided by imenu.
* ITEM is an overlay pointing to a tag provided by imenu with semantic mode.
* ITEM is a raw number pointing to a buffer position.
* ITEM is a cons: special case for imenu elements of an `org-mode' buffer.
ITEM is an imenu sub-tree and the position is stored as a marker in the first
element's \\='org-imenu-marker text property.
* ITEM is a cons: special case for imenu elements of an `pdfview-mode' buffer.
In this case no position is stored directly, navigation to the tag must happen
via callback
FILE is the path the tag is in, so far it is only relevant for `pdfview-mode'
tags."
(declare (side-effect-free t))
(pcase (type-of item)
('marker
(cons (marker-buffer item) (marker-position item)))
('overlay
(cons (overlay-buffer item) (overlay-start item)))
('integer
(cons nil item))
('cons
(cond
((eq 'pdf-outline-imenu-activate-link (cadr item))
(with-no-warnings
(cons (find-buffer-visiting file) (lambda () (apply #'pdf-outline-imenu-activate-link item)))))
((get-text-property 0 'org-imenu-marker (car item))
(-let [org-marker (get-text-property 0 'org-imenu-marker (car item))]
(cons (marker-buffer org-marker) (marker-position org-marker))))))))