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
|
||||||
|
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
|
(interactive (list (funcall persp-interactive-completion-function
|
||||||
"Buffer: " (mapcar 'buffer-name (buffer-list)))))
|
"Buffer: " (mapcar 'buffer-name (buffer-list)))))
|
||||||
(let* ((perspectives (persp-get-perspectives-for-buffer (get-buffer buffer)))
|
(let* ((perspectives (persp-get-perspectives-for-buffer (get-buffer buffer)))
|
||||||
(perspective (if (> (length perspectives) 1)
|
(perspective (if (> (length perspectives) 1)
|
||||||
(funcall persp-interactive-completion-function perspectives)
|
(funcall persp-interactive-completion-function
|
||||||
|
(format "Select the perspective in which you would like to visit %s."
|
||||||
|
buffer)
|
||||||
|
perspectives)
|
||||||
(car 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)
|
(persp-switch perspective)
|
||||||
(if (get-buffer-window buffer)
|
(if (get-buffer-window buffer)
|
||||||
(set-frame-selected-window nil (get-buffer-window buffer))
|
(set-frame-selected-window nil (get-buffer-window buffer))
|
||||||
(switch-to-buffer 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