Function: treemacs--bookmark-handler

treemacs--bookmark-handler is an autoloaded and byte-compiled function defined in treemacs-bookmarks.el.

Signature

(treemacs--bookmark-handler RECORD)

Documentation

Open Treemacs into a bookmark RECORD.

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-bookmarks.el
;;;###autoload
(defun treemacs--bookmark-handler (record)
  "Open Treemacs into a bookmark RECORD."
  (let ((path (bookmark-prop-get record 'treemacs-bookmark-path)))
    (unless path
      ;; Don't rely on treemacs-pulse-on-failure to display the error, since the
      ;; error must be handled in bookmark.el.
      (user-error "Treemacs--bookmark-handler invoked for a non-Treemacs bookmark"))
    (treemacs-select-window)
    ;; XXX temporary workaround for incorrect move to a saved tag node
    ;; must be fixed after tags were rewritten in new extension api
    (if (and (listp path)
             (stringp (car path))
             (file-regular-p (car path)))
        (treemacs-goto-node (car path))
      (treemacs-goto-node path))
    ;; If the user has bookmarked a directory, they probably want to operate on
    ;; its contents. Expand it, and select the first child.
    (treemacs-with-current-button
     "Could not select the current bookmark"
     (when (eq (treemacs-button-get current-btn :state) 'dir-node-closed)
       (treemacs-TAB-action))
     (when (eq (treemacs-button-get current-btn :state) 'dir-node-open)
       (let ((depth (treemacs-button-get current-btn :depth))
             (next-button (next-button current-btn)))
         (when (and next-button (> (treemacs-button-get next-button :depth) depth))
           (treemacs-next-line 1)))))))