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 11:31:47 +0100
> I'm wondering if there is a discrepancy between the doc string of
> quit-window and its implementation:  The function is supposed to quit
> the current buffer, but what it seems to do is to quit the buffer in the
> selected window.

You're right.  The doc-string is wrong in other respects as well.  Does
the form below fit your needs?

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 and the only window on its frame, delete its frame
provided there are other frames left."
  (interactive)
  (let* ((window (or window (selected-window)))
	 (buffer (window-buffer window))
	 (frame (window-frame window))
	 window-solitary window-handled)
    (with-selected-window window
      (setq window-solitary (one-window-p t))
      (unless (or (window-minibuffer-p) (window-dedicated-p))
	(switch-to-buffer (other-buffer))))
    ;; Get rid of the frame, if it has just one dedicated window
    ;; and other visible frames exist.
    (when (and (or (window-minibuffer-p window)
		   (window-dedicated-p window))
	       window-solitary
	       (frame-visible-p frame))
      (unless (and (eq default-minibuffer-frame frame)
		   (= 1 (length (minibuffer-frame-list))))
	(delete-frame frame))
      (setq window-handled t))
    ;; Deal with the buffer.
    (if kill
	(kill-buffer buffer)
      (bury-buffer buffer))
    ;; Maybe get rid of the window.
    (when (and (not window-handled) (not window-solitary))
      (delete-window window))))





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.