refactor(ibuffer): +ibuffer/visit-workspace-buffer
This commit is contained in:
parent
065e005db9
commit
8e33d2d04a
1 changed files with 13 additions and 14 deletions
|
@ -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)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue