GNU bug report logs - #1259
quit-window: does it quit the wrong buffer?

Previous Next

Package: emacs;

Reported by: David Reitter <david.reitter <at> gmail.com>

Date: Mon, 27 Oct 2008 01:30:02 UTC

Severity: normal

Done: martin rudalics <rudalics <at> gmx.at>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: martin rudalics <rudalics <at> gmx.at>
To: David Reitter <david.reitter <at> gmail.com>
Cc: 1259 <at> debbugs.gnu.org
Subject: bug#1259: quit-window: does it quit the wrong buffer?
Date: Mon, 27 Oct 2008 18:07:36 +0100
`quit-window' looks fishy in a number of regards: The `delete-frame'
stuff needs other_visible_frames to work correctly but this is not
available in Elisp.  I plan to commit somthing like the version below.
Could people please test whether it breaks their favorite use of this?

martin


(defun quit-window (&optional kill window)
  "Bury or kill (with KILL non-nil) the buffer displayed in WINDOW.
KILL defaults to nil, WINDOW to the selected window.  If WINDOW
is dedicated or a minibuffer window, delete it and, if it's the
only window on its frame, delete its frame as well provided there
are other frames left.  Otherwise, display some other buffer in
the window."
  (interactive)
  (let* ((window (or window (selected-window)))
	 (buffer (window-buffer window)))
    (if (or (window-minibuffer-p window) (window-dedicated-p window))
	(if (eq window (frame-root-window (window-frame window)))
	    ;; If this is the only window on its frame, try to delete the
	    ;; frame (`delete-windows-on' knows how to do that).
	    (delete-windows-on buffer (selected-frame))
	  ;; Other windows are left, delete this window.  But don't
	  ;; throw an error if that fails for some reason.
	  (condition-case nil
	      (delete-window window)
	    (error nil)))
      ;; The window is neither dedicated nor a minibuffer window,
      ;; display another buffer in it.
      (with-selected-window window
	(switch-to-buffer (other-buffer))))

    ;; Deal with the buffer.
    (if kill
	(kill-buffer buffer)
      (bury-buffer buffer))))





This bug report was last modified 16 years and 285 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.