all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Toggle between Vertical and Horizontal Windows Splitting
@ 2008-11-14 13:43 Nordlöw
  2008-11-14 13:54 ` Fabrice Niessen
  0 siblings, 1 reply; 3+ messages in thread
From: Nordlöw @ 2008-11-14 13:43 UTC (permalink / raw)
  To: help-gnu-emacs

Requested: Function that toggles between vertical and horizontal split
layout of currently defined windows preferrably preserving splitting
ratio.

Thanks in advance,
Nordlöw


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

* Re: Toggle between Vertical and Horizontal Windows Splitting
  2008-11-14 13:43 Toggle between Vertical and Horizontal Windows Splitting Nordlöw
@ 2008-11-14 13:54 ` Fabrice Niessen
  2008-11-14 14:42   ` Nordlöw
  0 siblings, 1 reply; 3+ messages in thread
From: Fabrice Niessen @ 2008-11-14 13:54 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

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 (on http://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" on http://www.MyGooglest.com


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

* Re: Toggle between Vertical and Horizontal Windows Splitting
  2008-11-14 13:54 ` Fabrice Niessen
@ 2008-11-14 14:42   ` Nordlöw
  0 siblings, 0 replies; 3+ messages in thread
From: Nordlöw @ 2008-11-14 14:42 UTC (permalink / raw)
  To: help-gnu-emacs

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


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

end of thread, other threads:[~2008-11-14 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-14 13:43 Toggle between Vertical and Horizontal Windows Splitting Nordlöw
2008-11-14 13:54 ` Fabrice Niessen
2008-11-14 14:42   ` Nordlöw

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.