Last active
September 29, 2015 23:08
-
-
Save rawsyntax/1683375 to your computer and use it in GitHub Desktop.
swap two windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'cl) | |
(defun swap-windows () | |
"If you have 2 windows, it swaps them." | |
(interactive) | |
(cond ((not (= (count-windows) 2)) | |
(message "You need exactly 2 windows to do this.")) | |
(t | |
(let* ((w1 (first (window-list))) | |
(w2 (second (window-list))) | |
(b1 (window-buffer w1)) | |
(b2 (window-buffer w2)) | |
(s1 (window-start w1)) | |
(s2 (window-start w2))) | |
(set-window-buffer w1 b2) | |
(set-window-buffer w2 b1) | |
(set-window-start w1 s2) | |
(set-window-start w2 s1))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment