all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* rotate split windows
@ 2006-12-04 13:33 wim yedema
  2006-12-04 21:22 ` Dieter Wilhelm
  0 siblings, 1 reply; 9+ messages in thread
From: wim yedema @ 2006-12-04 13:33 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 237 bytes --]

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 to do this?

Thanks,
Wim Yedema

[-- Attachment #1.2: Type: text/html, Size: 271 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: rotate split windows
       [not found] <mailman.1515.1165253652.2155.help-gnu-emacs@gnu.org>
@ 2006-12-04 19:54 ` Markus Triska
  2006-12-05 10:09   ` Marco Wahl
  0 siblings, 1 reply; 9+ messages in thread
From: Markus Triska @ 2006-12-04 19:54 UTC (permalink / raw)


"wim yedema" <wim.yedema@gmail.com> writes:


> 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 to
> do this?


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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: rotate split windows
  2006-12-04 13:33 rotate split windows wim yedema
@ 2006-12-04 21:22 ` Dieter Wilhelm
  0 siblings, 0 replies; 9+ messages in thread
From: Dieter Wilhelm @ 2006-12-04 21:22 UTC (permalink / raw)
  Cc: help-gnu-emacs

"wim yedema" <wim.yedema@gmail.com> writes:

> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: rotate split windows
  2006-12-04 19:54 ` Markus Triska
@ 2006-12-05 10:09   ` Marco Wahl
  2006-12-05 21:03     ` Chris Menzel
  2006-12-06 18:12     ` Markus Triska
  0 siblings, 2 replies; 9+ messages in thread
From: Marco Wahl @ 2006-12-05 10:09 UTC (permalink / raw)


Markus Triska <triska@gmx.at> writes:

> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: rotate split windows
  2006-12-05 10:09   ` Marco Wahl
@ 2006-12-05 21:03     ` Chris Menzel
  2006-12-06 18:12     ` Markus Triska
  1 sibling, 0 replies; 9+ messages in thread
From: Chris Menzel @ 2006-12-05 21:03 UTC (permalink / raw)


On 05 Dec 2006 11:09:28 +0100, Marco Wahl <mw@visenso.de> said:
> Markus Triska <triska@gmx.at> writes:
>
>> 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

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)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: rotate split windows
  2006-12-05 10:09   ` Marco Wahl
  2006-12-05 21:03     ` Chris Menzel
@ 2006-12-06 18:12     ` Markus Triska
  2006-12-06 21:34       ` Chris Menzel
                         ` (2 more replies)
  1 sibling, 3 replies; 9+ messages in thread
From: Markus Triska @ 2006-12-06 18:12 UTC (permalink / raw)


Marco Wahl <mw@visenso.de> writes:

> 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)))))

All the best,
Markus Triska

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: rotate split windows
  2006-12-06 18:12     ` Markus Triska
@ 2006-12-06 21:34       ` Chris Menzel
  2006-12-07  8:34       ` wim yedema
       [not found]       ` <mailman.1633.1165480499.2155.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 9+ messages in thread
From: Chris Menzel @ 2006-12-06 21:34 UTC (permalink / raw)


On Wed, 06 Dec 2006 19:12:28 +0100, Markus Triska <triska@gmx.at> said:
> Marco Wahl <mw@visenso.de> writes:
>
> The code posted by Chris only rotates the buffers and doesn't flip the
> split as requested; 

Whoops, missed that feature request. :-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: rotate split windows
  2006-12-06 18:12     ` Markus Triska
  2006-12-06 21:34       ` Chris Menzel
@ 2006-12-07  8:34       ` wim yedema
       [not found]       ` <mailman.1633.1165480499.2155.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 9+ messages in thread
From: wim yedema @ 2006-12-07  8:34 UTC (permalink / raw)
  Cc: help-gnu-emacs

> Marco Wahl <mw@visenso.de> writes:
>
> > alternative for [...] GNU Emacs 21.3.1
>
> No nice one (you can calculate the split using `window-egdes'):
Unfortunately I also have version 21.3.1.
I think it's safe to say that no one is going to make this for me?

What version of emacs should I use to get the window-tree?

Wim

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: rotate split windows
       [not found]       ` <mailman.1633.1165480499.2155.help-gnu-emacs@gnu.org>
@ 2006-12-07 17:35         ` Markus Triska
  0 siblings, 0 replies; 9+ messages in thread
From: Markus Triska @ 2006-12-07 17:35 UTC (permalink / raw)


"wim yedema" <wim.yedema@gmail.com> writes:

> What version of emacs should I use to get the window-tree?

Try CVS trunk.

All the best, Markus Triska

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-12-07 17:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-04 13:33 rotate split windows wim yedema
2006-12-04 21:22 ` Dieter Wilhelm
     [not found] <mailman.1515.1165253652.2155.help-gnu-emacs@gnu.org>
2006-12-04 19:54 ` Markus Triska
2006-12-05 10:09   ` Marco Wahl
2006-12-05 21:03     ` Chris Menzel
2006-12-06 18:12     ` Markus Triska
2006-12-06 21:34       ` Chris Menzel
2006-12-07  8:34       ` wim yedema
     [not found]       ` <mailman.1633.1165480499.2155.help-gnu-emacs@gnu.org>
2006-12-07 17:35         ` Markus Triska

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.