Sorry for the delay. On 27 Oct 2008, at 13:07, martin rudalics wrote: > `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? Is there a reason why you're not calling delete-window-on in all cases? Why the condition-case only for delete-window? Also, why the explicit switch-to-buffer? Should quit-window switch to the buffer that would be displayed if the current buffer was killed or just buried? - David > > > (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)))) >