[Top][All Lists]

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

delete-window when alone in frame deletes frame too

From: Drew Adams
Subject: delete-window when alone in frame deletes frame too
Date: Wed, 16 Jun 2004 10:25:54 -0700

I use frames instead of windows, by default, so the frames are nearly always
one-window-p. I use the following redefinition of delete-window. I wonder if
this functionality wouldn't make sense for Emacs, in general. It lets you
use C-x 0 to delete both windows and (one-window) frames.

Obviously, if such a change is made, it should be made in the C code,
instead of this way.

(or (fboundp 'old-delete-window)
    (fset 'old-delete-window (symbol-function 'delete-window)))

(defun delete-window (&optional window)
  "Remove WINDOW from the display.  Default is `selected-window'.
If WINDOW is the only one in its frame, then `delete-frame' too."
  (setq window (or window (selected-window)))
  (select-window window)
  (if (one-window-p) (delete-frame) (old-delete-window (selected-window))))

Note: If the frame is a minibuffer-only frame or the sole frame, an error is
thrown anyway, which is adequate protection.

reply via email to

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