Add this to your .emacs:
(defun rotate-split ()
(interactive)
(let ((root (car (window-tree))))
(if (listp root)
(let* ((w1 (nth 2 root))
(w2 (nth 3 root))
(b1 (window-buffer w1))
(b2 (window-buffer w2)))
(cond ((car root) ; currently vertically split
(delete-window w2)
(set-window-buffer (split-window-horizontally) b2))
(t ; currently horizontally split
(delete-window w1)
(set-window-buffer (split-window-vertically) b1))))
(message "Root window not split"))))
and invoke it with M-x rotate-split.
You can add this:
(global-set-key [f9] 'rotate-split)
to bind it to the function key F9 (for example).
The clockwise direction is analogous.
All the best,
Markus Triska
> Hi,
> I would like to be able to "rotate" the split between windows,
> eg: from (A, B) vertical to (A, B) horizonal, to (B, A) vertical, to
> (B, A) horizontal, and the other way around. Can anyone tell me how
Can I assume that there are only two windows (A,B) in your Emacs
frame?
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
> Add this to your .emacs:
>
>
> (defun rotate-split ()
> (interactive)
> (let ((root (car (window-tree))))
> [...]
Calling the function gives
car: Symbol's function definition is void: window-tree
Is there an alternative for
$ emacs --version
GNU Emacs 21.3.1
?
TIA
--
Marco Wahl
http://visenso.com
Give this a try:
(defun rotate-window-buffers()
(interactive)
(let* ((windows (window-list))
(buffers (mapcar #'window-buffer windows))
(wpoints (mapcar #'window-point windows))
(w (pop windows)))
(setq windows (append windows `(,w)))
(mapc (lambda(w)
(let ((b (pop buffers))
(p (pop wpoints)))
(set-window-buffer w b)
(set-window-point w p)))
windows)))
(define-key global-map [f7] 'rotate-window-buffers)
> alternative for [...] GNU Emacs 21.3.1
No nice one (you can calculate the split using `window-egdes'):
Primitives to look inside of window configurations would make sense,
but none are implemented.
The code posted by Chris only rotates the buffers and doesn't flip the
split as requested; a more concise version:
(defun rotate-window-buffers ()
(interactive)
(let* ((ws (window-list))
(bs (mapcar 'window-buffer ws))
(ps (mapcar 'window-point ws))
(w (pop ws)))
(dolist (v (append ws `(,w)))
(set-window-buffer v (pop bs))
(set-window-point v (pop ps)))))
Whoops, missed that feature request. :-)
What version of emacs should I use to get the window-tree?
Wim
> What version of emacs should I use to get the window-tree?
Try CVS trunk.