Gergely Polonkai
a7f07baa28
It exchanges the position of two windows. Works only if there are exactly two windows open.
12 lines
495 B
EmacsLisp
12 lines
495 B
EmacsLisp
(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))))))
|