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)))
|
||||
|
||||
(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."
|
||||
(interactive (list (funcall persp-interactive-completion-function
|
||||
"Buffer: " (mapcar 'buffer-name (buffer-list)))))
|
||||
(let* ((perspectives (persp-get-perspectives-for-buffer (get-buffer buffer)))
|
||||
(perspective (if (> (length perspectives) 1)
|
||||
(funcall persp-interactive-completion-function perspectives)
|
||||
(car perspectives))))
|
||||
(persp-switch perspective)
|
||||
(if (get-buffer-window buffer)
|
||||
(set-frame-selected-window nil (get-buffer-window buffer))
|
||||
(switch-to-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."
|
||||
(interactive (list (funcall persp-interactive-completion-function
|
||||
"Buffer: " (mapcar 'buffer-name (buffer-list)))))
|
||||
(let* ((perspectives (persp-get-perspectives-for-buffer (get-buffer buffer)))
|
||||
(perspective (if (> (length perspectives) 1)
|
||||
(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)
|
||||
(interactive "P")
|
||||
|
Loading…
Reference in New Issue
Block a user