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 18:07:36 +0100
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

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







reply via email to

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