Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add rotate-windows function.

  • Loading branch information...
commit 3cc572daf3148a1aebe2fc69c1c93e462dba2fee 1 parent 3f9838b
Craig Andera authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 init.el
28 init.el
View
@@ -189,6 +189,34 @@ Accepts WIDTH as a numeric prefix, but defaults to 85."
(global-set-key (kbd "C-x 4 3") 'temporarily-display-three-windows)
(global-set-key (kbd "C-x 4 4") 'temporarily-display-four-windows)
+;; Flips the left and right windows. Taken from
+;; http://whattheemacsd.com//buffer-defuns.el-02.html
+(defun rotate-windows ()
+ "Rotate your windows"
+ (interactive)
+ (cond ((not (> (count-windows) 1))
+ (message "You can't rotate a single window!"))
+ (t
+ (setq i 1)
+ (setq numWindows (count-windows))
+ (while (< i numWindows)
+ (let* (
+ (w1 (elt (window-list) i))
+ (w2 (elt (window-list) (+ (% i numWindows) 1)))
+
+ (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)
+ (setq i (1+ i)))))))
+
+
;; Cursor-style setting functions
(defun set-cursor-type (cursor)
"Modify the cursor to the specified type"
Please sign in to comment.
Something went wrong with that request. Please try again.