Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rotate buffers in open windows, courtesy of @magnars.

  • Loading branch information...
commit 5d9b0a2aa214da0e6d400bc8515241a5681ae29c 1 parent 308ba4b
@bodil authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 bodil-nav.el
View
28 bodil-nav.el
@@ -49,4 +49,32 @@
;; Highlight current tree item
(add-hook 'project-explorer-mode-hook 'hl-line-mode)
+;; Transpose (rotate if multiple) windows
+(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)))))))
+
+(global-set-key (kbd "C-x C-o") 'rotate-windows)
+
(provide 'bodil-nav)
Please sign in to comment.
Something went wrong with that request. Please try again.