refactor(ibuffer): +ibuffer/visit-workspace-buffer

This commit is contained in:
Henrik Lissner 2022-04-03 21:06:35 +02:00
parent 065e005db9
commit 8e33d2d04a
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -18,18 +18,17 @@
"Visit buffer, but switch to its workspace if it exists." "Visit buffer, but switch to its workspace if it exists."
(interactive "P") (interactive "P")
(let ((buf (ibuffer-current-buffer t))) (let ((buf (ibuffer-current-buffer t)))
(if (not (buffer-live-p buf)) (unless (buffer-live-p buf)
(user-error "Not a valid or live buffer: %s" buf) (user-error "Not a valid or live buffer: %s" buf))
(when-let (workspaces (if-let (workspaces
(cl-loop for wk in (+workspace-list) (cl-loop for wk in (+workspace-list)
if (+workspace-contains-buffer-p buf wk) if (+workspace-contains-buffer-p buf wk)
collect wk)) collect wk))
(+workspace-switch (+workspace-switch
(persp-name
(if (and (not select-first) (cdr workspaces)) (if (and (not select-first) (cdr workspaces))
(+workspace-get
(or (completing-read "Select workspace: " (mapcar #'persp-name workspaces)) (or (completing-read "Select workspace: " (mapcar #'persp-name workspaces))
(user-error "Aborted"))) (user-error "Aborted"))
(car workspaces))))) (persp-name (car workspaces))))
(persp-add-buffer buf) ; then add the buffer to the current workspace ;; Or add the buffer to the current workspace
(switch-to-buffer buf)))) (persp-add-buffer buf))
(switch-to-buffer buf)))