Add transpose-windows defun
It exchanges the position of two windows. Works only if there are exactly two windows open.
This commit is contained in:
parent
384bdce01c
commit
a7f07baa28
1
init.el
1
init.el
@ -67,6 +67,7 @@
|
|||||||
(load "toggle-window-split.el")
|
(load "toggle-window-split.el")
|
||||||
(load "round-number-to-decimals.el")
|
(load "round-number-to-decimals.el")
|
||||||
(load "clearcase.el")
|
(load "clearcase.el")
|
||||||
|
(load "transpose-windows.el")
|
||||||
|
|
||||||
(add-hook 'c-mode-hook 'helm-gtags-mode)
|
(add-hook 'c-mode-hook 'helm-gtags-mode)
|
||||||
(add-hook 'c-mode-hook 'which-func-mode)
|
(add-hook 'c-mode-hook 'which-func-mode)
|
||||||
|
11
transpose-windows.el
Normal file
11
transpose-windows.el
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
(defun transpose-windows (arg)
|
||||||
|
"Transpose the buffers shown in two windows."
|
||||||
|
(interactive "p")
|
||||||
|
(let ((selector (if (>= arg 0) 'next-window 'previous-window)))
|
||||||
|
(while (/= arg 0)
|
||||||
|
(let ((this-win (window-buffer))
|
||||||
|
(next-win (window-buffer (funcall selector))))
|
||||||
|
(set-window-buffer (selected-window) next-win)
|
||||||
|
(set-window-buffer (funcall selector) this-win)
|
||||||
|
(select-window (funcall selector)))
|
||||||
|
(setq arg (if (plusp arg) (1- arg) (1+ arg))))))
|
Loading…
Reference in New Issue
Block a user