fix(workspaces): "none" workspace
Doom removes the "none" workspace from persp-mode's default list of
perspectives, because it is a special case that doesn't behave
identically to other persps in the list, making it a pain to deal with.
This worked fine up until a change to `persp-update-names-cache` (in
Bad-ptr/persp-mode.el@0d6cacc) made it re-insert this "none" workspace
into `persp-names-cache` whenever it is called, undoing our hack; this
commit adapts to that change.
Ref: Bad-ptr/persp-mode.el@0d6caccab3
Ref: Bad-ptr/persp-mode.el@b2e68f97cb
Fix: #7986
Amend: 7f3412e317
This commit is contained in:
parent
7f3412e317
commit
b3bea23331
2 changed files with 12 additions and 15 deletions
|
@ -63,20 +63,20 @@ error if NAME doesn't exist."
|
||||||
"Get the name of the current workspace."
|
"Get the name of the current workspace."
|
||||||
(safe-persp-name (+workspace-current)))
|
(safe-persp-name (+workspace-current)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +workspace-list-names ()
|
||||||
|
"Return the list of names of open workspaces."
|
||||||
|
(cl-remove persp-nil-name persp-names-cache :count 1))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +workspace-list ()
|
(defun +workspace-list ()
|
||||||
"Return a list of workspace structs (satisifes `+workspace-p')."
|
"Return a list of workspace structs (satisifes `+workspace-p')."
|
||||||
;; We don't use `hash-table-values' because it doesn't ensure order in older
|
;; We don't use `hash-table-values' because it doesn't ensure order in older
|
||||||
;; versions of Emacs
|
;; versions of Emacs
|
||||||
(cl-loop for name in persp-names-cache
|
(cl-loop for name in (+workspace-list-names)
|
||||||
if (gethash name *persp-hash*)
|
if (gethash name *persp-hash*)
|
||||||
collect it))
|
collect it))
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +workspace-list-names ()
|
|
||||||
"Return the list of names of open workspaces."
|
|
||||||
persp-names-cache)
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +workspace-buffer-list (&optional persp)
|
(defun +workspace-buffer-list (&optional persp)
|
||||||
"Return a list of buffers in PERSP.
|
"Return a list of buffers in PERSP.
|
||||||
|
@ -193,7 +193,7 @@ throws an error."
|
||||||
(let ((old-name (+workspace-current-name)))
|
(let ((old-name (+workspace-current-name)))
|
||||||
(unless (equal old-name name)
|
(unless (equal old-name name)
|
||||||
(setq +workspace--last
|
(setq +workspace--last
|
||||||
(or (and (not (string= old-name persp-nil-name))
|
(or (and (not (+workspace--protected-p old-name))
|
||||||
old-name)
|
old-name)
|
||||||
+workspaces-main))
|
+workspaces-main))
|
||||||
(persp-frame-switch name))
|
(persp-frame-switch name))
|
||||||
|
@ -398,7 +398,7 @@ end of the workspace list."
|
||||||
"Cycle n workspaces to the right (default) or left."
|
"Cycle n workspaces to the right (default) or left."
|
||||||
(interactive (list 1))
|
(interactive (list 1))
|
||||||
(let ((current-name (+workspace-current-name)))
|
(let ((current-name (+workspace-current-name)))
|
||||||
(if (equal current-name persp-nil-name)
|
(if (+workspace--protected-p current-name)
|
||||||
(+workspace-switch +workspaces-main t)
|
(+workspace-switch +workspaces-main t)
|
||||||
(condition-case-unless-debug ex
|
(condition-case-unless-debug ex
|
||||||
(let* ((persps (+workspace-list-names))
|
(let* ((persps (+workspace-list-names))
|
||||||
|
@ -446,9 +446,10 @@ the next."
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(let* ((current-name (+workspace-current-name))
|
(let* ((current-name (+workspace-current-name))
|
||||||
(count (or count 1))
|
(count (or count 1))
|
||||||
(index (- (cl-position current-name persp-names-cache :test #'equal)
|
(persps (+workspace-list-names))
|
||||||
|
(index (- (cl-position current-name persps :test #'equal)
|
||||||
count))
|
count))
|
||||||
(names (remove current-name persp-names-cache)))
|
(names (remove current-name persps)))
|
||||||
(unless names
|
(unless names
|
||||||
(user-error "Only one workspace"))
|
(user-error "Only one workspace"))
|
||||||
(let ((index (min (max 0 index) (length names))))
|
(let ((index (min (max 0 index) (length names))))
|
||||||
|
@ -575,7 +576,7 @@ This be hooked to `projectile-after-switch-project-hook'."
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(if (and (not (null +workspaces-on-switch-project-behavior))
|
(if (and (not (null +workspaces-on-switch-project-behavior))
|
||||||
(or (eq +workspaces-on-switch-project-behavior t)
|
(or (eq +workspaces-on-switch-project-behavior t)
|
||||||
(equal (safe-persp-name (get-current-persp)) persp-nil-name)
|
(+workspace--protected-p (safe-persp-name (get-current-persp)))
|
||||||
(+workspace-buffer-list)))
|
(+workspace-buffer-list)))
|
||||||
(let* ((persp
|
(let* ((persp
|
||||||
(let ((project-name (doom-project-name +workspaces--project-dir)))
|
(let ((project-name (doom-project-name +workspaces--project-dir)))
|
||||||
|
|
|
@ -73,10 +73,6 @@ stored in `persp-save-dir'.")
|
||||||
"Ensure a main workspace exists."
|
"Ensure a main workspace exists."
|
||||||
(when persp-mode
|
(when persp-mode
|
||||||
(let (persp-before-switch-functions)
|
(let (persp-before-switch-functions)
|
||||||
;; Try our best to hide the nil perspective.
|
|
||||||
(when (equal (car persp-names-cache) persp-nil-name)
|
|
||||||
(pop persp-names-cache))
|
|
||||||
;; ...and create a *real* main workspace to fill this role.
|
|
||||||
(unless (or (persp-get-by-name +workspaces-main)
|
(unless (or (persp-get-by-name +workspaces-main)
|
||||||
;; Start from 2 b/c persp-mode counts the nil workspace
|
;; Start from 2 b/c persp-mode counts the nil workspace
|
||||||
(> (hash-table-count *persp-hash*) 2))
|
(> (hash-table-count *persp-hash*) 2))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue