[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Toggle between Vertical and Horizontal Windows Splitting
From: |
Nordlöw |
Subject: |
Re: Toggle between Vertical and Horizontal Windows Splitting |
Date: |
Fri, 14 Nov 2008 06:42:12 -0800 (PST) |
User-agent: |
G2/1.0 |
On 14 Nov, 14:54, "Fabrice Niessen" <tdhkhcidi...@spammotel.com>
wrote:
> Nordlöw,
>
> > Requested: Function that toggles between vertical and
> > horizontal split layout of currently defined windows
> > preferrably preserving splitting ratio.
>
> You can find the following:
>
> --8<---------------cut here---------------start------------->8---
> (defun my-toggle-window-split ()
> "Vertical split shows more of each line, horizontal split shows
> more lines. This code toggles between them. It only works for
> frames with exactly two windows."
> (interactive)
> (if (= (count-windows) 2)
> (let* ((this-win-buffer (window-buffer))
> (next-win-buffer (window-buffer (next-window)))
> (this-win-edges (window-edges (selected-window)))
> (next-win-edges (window-edges (next-window)))
> (this-win-2nd (not (and (<= (car this-win-edges)
> (car next-win-edges))
> (<= (cadr this-win-edges)
> (cadr next-win-edges)))))
> (splitter
> (if (= (car this-win-edges)
> (car (window-edges (next-window))))
> 'split-window-horizontally
> 'split-window-vertically)))
> (delete-other-windows)
> (let ((first-win (selected-window)))
> (funcall splitter)
> (if this-win-2nd (other-window 1))
> (set-window-buffer (selected-window) this-win-buffer)
> (set-window-buffer (next-window) next-win-buffer)
> (select-window first-win)
> (if this-win-2nd (other-window 1))))))
>
> (global-set-key [(control c) (|)] 'my-toggle-window-split)
> --8<---------------cut here---------------end--------------->8---
>
> in my `.emacs' file (onhttp://www.mygooglest.com/fni/dot-emacs.html).
>
> FYI, this has been taken from the excellent EmacsWiki:
>
> http://www.emacswiki.org/emacs/ToggleWindowSplit
>
> Best regards,
> Fabrice
>
> _________________________________________________________________________
> Fabrice Niessen
> Search the Web with "My Google Search Tools" onhttp://www.MyGooglest.com
Thanks!
/Nordlöw