Function: treemacs-do-remove-workspace

treemacs-do-remove-workspace is a byte-compiled function defined in treemacs-workspaces.el.

Signature

(treemacs-do-remove-workspace &optional WORKSPACE ASK-TO-CONFIRM)

Documentation

Delete a WORKSPACE.

Ask the user to confirm the deletion when ASK-TO-CONFIRM is t (it will be when this is called from treemacs-remove-workspace).

If no WORKSPACE name is given it will be selected interactively.

Return values may be as follows:

* If only a single workspace remains:
  - the symbol only-one-workspace
* If the user cancels the deletion:
  - the symbol user-cancel
* If the workspace cannot be found:
  - the symbol workspace-not-found
* If everything went well:
  - the symbol success
  - the deleted workspace
  - the list of the remaining workspaces

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-workspaces.el
(defun treemacs-do-remove-workspace (&optional workspace ask-to-confirm)
  "Delete a WORKSPACE.
Ask the user to confirm the deletion when ASK-TO-CONFIRM is t (it will be when
this is called from `treemacs-remove-workspace').

If no WORKSPACE name is given it will be selected interactively.

Return values may be as follows:

* If only a single workspace remains:
  - the symbol `only-one-workspace'
* If the user cancels the deletion:
  - the symbol `user-cancel'
* If the workspace cannot be found:
  - the symbol `workspace-not-found'
* If everything went well:
  - the symbol `success'
  - the deleted workspace
  - the list of the remaining workspaces"
  (treemacs-block
   (treemacs-return-if (= 1 (length treemacs--workspaces))
     'only-one-workspace)
   (let* ((name (or workspace
                    (completing-read "Delete: " (-map #'treemacs-workspace->name treemacs--workspaces) nil t)))
          (to-delete (treemacs-find-workspace-by-name name)))
     (treemacs-return-if
         (and ask-to-confirm
              (not (yes-or-no-p (format "Delete workspace %s and all its projects?"
                                        (propertize (treemacs-workspace->name to-delete)
                                                    'face 'font-lock-type-face)))))
       'user-cancel)
     (treemacs-return-if (null to-delete)
       `(workspace-not-found ,name))
     (setq treemacs--workspaces (delete to-delete treemacs--workspaces))
     (treemacs--persist)
     (treemacs--invalidate-buffer-project-cache)
     (treemacs-run-in-every-buffer
      (let ((current-ws (treemacs-current-workspace)))
        (when (eq current-ws to-delete)
          (treemacs--rerender-after-workspace-change))))
     (run-hook-with-args 'treemacs-delete-workspace-functions to-delete)
     `(success ,to-delete ,treemacs--workspaces))))