help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: defun not working


From: rgb
Subject: Re: defun not working
Date: 20 Jul 2005 12:32:21 -0700
User-agent: G2/0.2

> > Hello
> > I have this in my ~/.emacs
>
> > (defun edo-vertical-to-horizontal ()
> > (interactive)
> > (let ((one-buf (window-buffer (selected-window))))
> > (other-window 1)
> > (delete-other-window)
> > (split-window-horizontally)
> > (switch-to-buffer one-buf))
>

After using the above for a while you might become annoyed
by the loss of your cursor position when switching views.
So I use this.

  ;; Idea and starter code from Benjamin Rutt (rutt.4+news@osu.edu)
  ;; on comp.emacs. Enhanced by RGB.
  (defun rgb-window-horizontal-to-vertical ()
    "Switches from a horizontal split to a vertical split."
    (interactive)
    (let ((one-buf (window-buffer (selected-window)))
          (buf-point (point)))
      (other-window 1)
      (delete-other-windows)
      (split-window-horizontally)
      (switch-to-buffer one-buf)
      (goto-char buf-point)))

  ;; complement of above created by RGB 11/2004
  (defun rgb-window-vertical-to-horizontal ()
    "Switches from a vertical split to a horizontal split."
    (interactive)
    (let ((one-buf (window-buffer (selected-window)))
          (buf-point (point)))
      (other-window 1)
      (delete-other-windows)
      (split-window-vertically)
      (switch-to-buffer one-buf)
      (goto-char buf-point)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]