forked from colonelpanic/dotfiles
New persp-pick-perspective-by-buffer
.
This commit is contained in:
parent
ca2403c4df
commit
a690c0eadb
@ -1076,17 +1076,30 @@ marking if it still had that."
|
|||||||
collect (persp-name perspective)))
|
collect (persp-name perspective)))
|
||||||
|
|
||||||
(defun persp-pick-perspective-by-buffer (buffer)
|
(defun persp-pick-perspective-by-buffer (buffer)
|
||||||
"Select a buffer and go to the perspective to which that buffer belongs. If the buffer belongs to more than one perspective completion will be used to pick the perspective to switch to. Switch the focus to the window in which said buffer is displayed if such a window exists. Otherwise display the buffer in whatever window is active in the perspective."
|
"Select a buffer and go to the perspective to which that buffer
|
||||||
(interactive (list (funcall persp-interactive-completion-function
|
belongs. If the buffer belongs to more than one perspective
|
||||||
"Buffer: " (mapcar 'buffer-name (buffer-list)))))
|
completion will be used to pick the perspective to switch to.
|
||||||
(let* ((perspectives (persp-get-perspectives-for-buffer (get-buffer buffer)))
|
Switch the focus to the window in which said buffer is displayed
|
||||||
(perspective (if (> (length perspectives) 1)
|
if such a window exists. Otherwise display the buffer in whatever
|
||||||
(funcall persp-interactive-completion-function perspectives)
|
window is active in the perspective."
|
||||||
(car perspectives))))
|
(interactive (list (funcall persp-interactive-completion-function
|
||||||
(persp-switch perspective)
|
"Buffer: " (mapcar 'buffer-name (buffer-list)))))
|
||||||
(if (get-buffer-window buffer)
|
(let* ((perspectives (persp-get-perspectives-for-buffer (get-buffer buffer)))
|
||||||
(set-frame-selected-window nil (get-buffer-window buffer))
|
(perspective (if (> (length perspectives) 1)
|
||||||
(switch-to-buffer buffer))))
|
(funcall persp-interactive-completion-function
|
||||||
|
(format "Select the perspective in which you would like to visit %s."
|
||||||
|
buffer)
|
||||||
|
perspectives)
|
||||||
|
(car perspectives))))
|
||||||
|
(if (string= (persp-name persp-curr) perspective)
|
||||||
|
;; This allows the opening of a single buffer in more than one window
|
||||||
|
;; in a single perspective.
|
||||||
|
(switch-to-buffer buffer)
|
||||||
|
(progn
|
||||||
|
(persp-switch perspective)
|
||||||
|
(if (get-buffer-window buffer)
|
||||||
|
(set-frame-selected-window nil (get-buffer-window buffer))
|
||||||
|
(switch-to-buffer buffer))))))
|
||||||
|
|
||||||
(defun persp-mode-switch-buffers (arg)
|
(defun persp-mode-switch-buffers (arg)
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
|
Loading…
Reference in New Issue
Block a user