Function: treemacs-do-rename-workspace
treemacs-do-rename-workspace is a byte-compiled function defined in
treemacs-workspaces.el.
Signature
(treemacs-do-rename-workspace &optional WORKSPACE NEW-NAME)
Documentation
Rename a workspace.
Takes either a WORKSPACE and a NEW-NAME as arguments or reads them interactively.
Return values may be as follows:
* If the given name is invalid:
- the symbol invalid-name
- the name
* If everything went well:
- the symbol success
- the old-name
- the renamed workspace
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-workspaces.el
(defun treemacs-do-rename-workspace (&optional workspace new-name)
"Rename a workspace.
Takes either a WORKSPACE and a NEW-NAME as arguments or reads them
interactively.
Return values may be as follows:
* If the given name is invalid:
- the symbol `invalid-name'
- the name
* If everything went well:
- the symbol `success'
- the old-name
- the renamed workspace"
(treemacs-block
(let ((old-name))
(unless workspace
(let* ((current-ws (treemacs-current-workspace))
(old-name (treemacs-workspace->name current-ws))
(name-map (-> (--map (cons (treemacs-workspace->name it) it) treemacs--workspaces)
(sort (lambda (n _) (string= (car n) old-name)))))
(str-to-rename (completing-read "Rename: " name-map)))
(setf workspace (cdr (assoc str-to-rename name-map)))))
(setf old-name (treemacs-workspace->name workspace))
(unless new-name
(setf new-name (treemacs--read-string "New name: ")))
(treemacs-return-if (treemacs--is-name-invalid? new-name)
`(invalid-name ,new-name))
(setf (treemacs-workspace->name workspace) new-name)
(treemacs--persist)
(run-hook-with-args 'treemacs-rename-workspace-functions workspace old-name)
`(success ,old-name ,workspace))))