Function: treemacs-root-up
treemacs-root-up is an interactive and byte-compiled function defined
in treemacs-interface.el.
Signature
(treemacs-root-up &optional _)
Documentation
Move treemacs' root one level upward.
Only works with a single project in the workspace.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-interface.el
(defun treemacs-root-up (&optional _)
"Move treemacs' root one level upward.
Only works with a single project in the workspace."
(interactive "P")
(treemacs-block
(unless (= 1 (length (treemacs-workspace->projects (treemacs-current-workspace))))
(treemacs-error-return
"Ad-hoc navigation is only possible when there is but a single project in the workspace."))
(-let [btn (treemacs-current-button)]
(unless btn
(setq btn (previous-button (point))))
(let* ((project (-> btn (treemacs--nearest-path) (treemacs--find-project-for-path)))
(old-root (treemacs-project->path project))
(new-root (treemacs--parent old-root))
(new-name (pcase new-root
("/" new-root)
(_ (file-name-nondirectory new-root))))
(treemacs--no-messages t)
(treemacs-pulse-on-success nil))
(unless (treemacs-is-path old-root :same-as new-root)
(treemacs-do-remove-project-from-workspace project :ignore-last-project-restriction)
(treemacs--reset-dom) ;; remove also the previous root's dom entry
(treemacs-do-add-project-to-workspace new-root new-name)
(treemacs-goto-file-node old-root))))))