Function: treemacs-bookmark

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

Signature

(treemacs-bookmark &optional ARG)

Documentation

Find a bookmark in treemacs.

Only bookmarks marking either a file or a directory are offered for selection. Treemacs will try to find and focus the given bookmark's location, in a similar fashion to treemacs-find-file.

With a prefix argument ARG treemacs will also open the bookmarked location.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-bookmarks.el
;;;###autoload
(defun treemacs-bookmark (&optional arg)
  "Find a bookmark in treemacs.
Only bookmarks marking either a file or a directory are offered for selection.
Treemacs will try to find and focus the given bookmark's location, in a similar
fashion to `treemacs-find-file'.

With a prefix argument ARG treemacs will also open the bookmarked location."
  (interactive "P")
  (treemacs-block
   (bookmark-maybe-load-default-file)
   (-let [bookmarks
          (cl-loop
           for b in bookmark-alist
           for name = (car b)
           for location = (treemacs-canonical-path (bookmark-location b))
           when (or (file-regular-p location) (file-directory-p location))
           collect (propertize name 'location location))]
     (treemacs-error-return-if (null bookmarks)
       "Didn't find any bookmarks pointing to files.")
     (let* ((bookmark (completing-read "Bookmark: " bookmarks))
            (location (treemacs-canonical-path (get-text-property 0 'location (--first (string= it bookmark) bookmarks))))
            (dir (if (file-directory-p location) location (treemacs--parent-dir location)))
            (project (treemacs--find-project-for-path dir)))
       (treemacs-error-return-if (null project)
         "Bookmark at %s does not fall under any project in the workspace."
         (propertize location 'face 'font-lock-string-face))
       (pcase (treemacs-current-visibility)
         ('visible (treemacs--select-visible-window))
         ('exists  (treemacs--select-not-visible-window))
         ('none    (treemacs--init)))
       (treemacs-goto-file-node location project)
       (treemacs-pulse-on-success)
       (when arg (treemacs-visit-node-no-split))))))