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: David Reitter <david.reitter <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 1259 <at> debbugs.gnu.org
Subject: bug#1259: quit-window: does it quit the wrong buffer?
Date: Tue, 4 Nov 2008 12:40:47 -0500
[Message part 1 (text/plain, inline)]
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))))
>

[smime.p7s (application/pkcs7-signature, attachment)]

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.