unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* delete-window when alone in frame deletes frame too
@ 2004-06-16 17:25 Drew Adams
  2004-06-17 15:10 ` Kevin Rodgers
  0 siblings, 1 reply; 2+ messages in thread
From: Drew Adams @ 2004-06-16 17:25 UTC (permalink / raw)


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."
  (interactive)
  (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.

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

* Re: delete-window when alone in frame deletes frame too
  2004-06-16 17:25 delete-window when alone in frame deletes frame too Drew Adams
@ 2004-06-17 15:10 ` Kevin Rodgers
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2004-06-17 15:10 UTC (permalink / raw)


Drew Adams wrote:
 > (or (fboundp 'old-delete-window)
 >     (fset 'old-delete-window (symbol-function 'delete-window)))

Yuck.

(defadvice delete-window (around delete-frame activate compile)
   "If WINDOW is the only one in its frame, then delete the frame instead."
   (let ((window (or (ad-get-arg 0) (selected-window))))
     (select-window window)
     (if (one-window-p)
	(delete-frame)
       ad-do-it)))

-- 
Kevin Rodgers

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

end of thread, other threads:[~2004-06-17 15:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-16 17:25 delete-window when alone in frame deletes frame too Drew Adams
2004-06-17 15:10 ` Kevin Rodgers

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).