Function: treemacs-rename-project
treemacs-rename-project is an interactive and byte-compiled function
defined in treemacs-interface.el.
Signature
(treemacs-rename-project)
Documentation
Give the project at point a new name.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-interface.el
(defun treemacs-rename-project ()
"Give the project at point a new name."
(interactive)
(treemacs-with-writable-buffer
(treemacs-block
(treemacs-unless-let (project (treemacs-project-at-point))
(treemacs-pulse-on-failure "There is no project here.")
(let* ((old-name (treemacs-project->name project))
(project-btn (treemacs-project->position project))
(state (treemacs-button-get project-btn :state))
(new-name (treemacs--read-string "New name: " (treemacs-project->name project))))
(treemacs-save-position
(progn
(treemacs-return-if (treemacs--is-name-invalid? new-name)
(treemacs-pulse-on-failure "'%s' is an invalid name."
(propertize new-name 'face 'font-lock-type-face)))
(treemacs-return-if (string-equal old-name new-name)
(treemacs-pulse-on-failure "The new name is the same as the old name."))
(setf (treemacs-project->name project) new-name)
;; after renaming, delete and redisplay the project
(goto-char (treemacs-button-end project-btn))
(delete-region (line-beginning-position) (line-end-position))
(treemacs--add-root-element project)
(when (eq state 'root-node-open)
(treemacs--collapse-root-node (treemacs-project->position project))
(treemacs--expand-root-node (treemacs-project->position project))))
(run-hook-with-args 'treemacs-rename-project-functions project old-name)
(treemacs-pulse-on-success "Renamed project %s to %s."
(propertize old-name 'face 'font-lock-type-face)
(propertize new-name 'face 'font-lock-type-face)))))))
(treemacs--evade-image))