GNU bug report logs -
#1259
quit-window: does it quit the wrong buffer?
Previous Next
Full log
View this message in rfc822 format
> 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.