emacs-devel
[Top][All Lists]
Advanced

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

Re: C-x 3 (split-window-horizontally) & C-x 1 (delete-other-windows)


From: Tassilo Horn
Subject: Re: C-x 3 (split-window-horizontally) & C-x 1 (delete-other-windows)
Date: Mon, 05 May 2008 20:44:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

"Sam Steingold" <address@hidden> writes:

Hi Sam,

> When I split the emacs window horizontally and maximize the frame (X
> window), I get two 80-char-wide buffers + wide menu bar which can
> accommodate even the dired menus, which is very convenient.  I see 2
> issues with this arrangement:
>
> 1. even though I can imagine that I might want to have one 160-char-wide
>    window every once in a while, by far the more common situation would
>    be wanting to preserve 2 columns.  Thus I would want C-x 1 to delete
>    all other windows in the current column and leave the other column
>    intact (as if the other column were a separate frame glued to this
>    one side by side)

Yes, that's my preference, too.  I've bound the function
`th-delete-other-windows' to `C-x 1' to get that behavior.

--8<---------------cut here---------------start------------->8---
(require 'windmove)

(defun th-delete-other-windows-vertically ()
  "Delete all windows above or below the current window."
  (interactive)
  (let ((win (selected-window)))
    (save-excursion
      (while (condition-case nil (windmove-up) (error nil))
        (delete-window)
        (select-window win))
      (while (condition-case nil (windmove-down) (error nil))
        (delete-window)
        (select-window win)))))

(defun  th-delete-other-windows-horizontally ()
  "Delete all windows left or right of the current window."
  (interactive)
  (let ((win (selected-window)))
    (save-excursion
      (while (condition-case nil (windmove-left) (error nil))
        (delete-window)
        (select-window win))
      (while (condition-case nil (windmove-right) (error nil))
        (delete-window)
        (select-window win)))))

(defun th-delete-other-windows (&optional arg)
  "If ARG is 1 (no prefix arg given) or 2 delete all windows
which are above or below the current window. If ARG is 3 delete
all windows which are left or right of the current window. If
prefix arg is negative, delete all other windows."
  (interactive "p")
  (cond
   ((< arg 0) (delete-other-windows))
   ((= arg 2) (th-delete-other-windows-vertically))
   ((= arg 3) (th-delete-other-windows-horizontally))
   (t (th-delete-other-windows-vertically))))
--8<---------------cut here---------------end--------------->8---

A bit hackish, but works.

> 2. it would be nice to be able to drag the separator between the columns
>    with the mouse to resize the windows, much like it is done with the
>    vertically split windows (one can drag the mode line).

Well, here that's possible.  The mouse pointer turns to <-> on the right
fringe of the left window.

Bye,
Tassilo




reply via email to

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