bug-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: martin rudalics
Subject: bug#1259: quit-window: does it quit the wrong buffer?
Date: Mon, 27 Oct 2008 11:31:47 +0100
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

> 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))))







reply via email to

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