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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 1259 in the body.
You can then email your comments to 1259 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to David Reitter <david.reitter <at> gmail.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: David Reitter <david.reitter <at> gmail.com>
To: emacs-pretest-bug <at> gnu.org
Subject: quit-window: does it quit the wrong buffer?
Date: Sun, 26 Oct 2008 21:19:48 -0400
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.


(defun quit-window (&optional kill window)
  "Quit the current buffer.  Bury it, and maybe delete the selected  
frame.
\(The frame is deleted if it contains a dedicated window for the  
buffer.)
With a prefix argument, kill the buffer instead.

Noninteractively, if KILL is non-nil, then kill the current buffer,
otherwise bury it.

If WINDOW is non-nil, it specifies a window; we delete that window,
and the buffer that is killed or buried is the one in that window."
  (interactive "P")
  (let ((buffer (window-buffer window))
	(frame (window-frame (or window (selected-window))))




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #10 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: David Reitter <david.reitter <at> gmail.com>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: bug#1259: quit-window: does it quit the wrong buffer?
Date: Mon, 27 Oct 2008 11:31:47 +0100
> 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))))





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to David Reitter <david.reitter <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #15 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: David Reitter <david.reitter <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: bug#1259: quit-window: does it quit the wrong buffer?
Date: Mon, 27 Oct 2008 11:01:39 -0400
[Message part 1 (text/plain, inline)]
On 27 Oct 2008, at 06:31, martin rudalics wrote:

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

The doc string you sent seems appropriate to me, thanks. 
[smime.p7s (application/pkcs7-signature, attachment)]

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #20 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: David Reitter <david.reitter <at> gmail.com>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: bug#1259: quit-window: does it quit the wrong buffer?
Date: Mon, 27 Oct 2008 18:07:36 +0100
`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 sent to martin rudalics <rudalics <at> gmx.at>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to David Reitter <david.reitter <at> gmail.com>:
bug acknowledged by developer. Full text and rfc822 format available.

Message #25 received at 1259-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: 1259-done <at> debbugs.gnu.org
Cc: David Reitter <david.reitter <at> gmail.com>
Subject: Re: bug#1259: quit-window: does it quit the wrong buffer?
Date: Thu, 30 Oct 2008 16:42:17 +0100
Fixed as

2008-10-30  Martin Rudalics  <rudalics <at> gmx.at>

	* window.el (quit-window): Simplify code.  Say in doc-string
	that it operates on the selected window's buffer.  (Bug#1259)

Thanks, martin




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to David Reitter <david.reitter <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #30 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: David Reitter <david.reitter <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: 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)]

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #35 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: David Reitter <david.reitter <at> gmail.com>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: bug#1259: quit-window: does it quit the wrong buffer?
Date: Tue, 04 Nov 2008 19:15:40 +0100
> Is there a reason why you're not calling delete-window-on in all cases?

Just for the case that I have two windows showing the same buffer and
invoke `quit-window' on one of them.  In this case I want to leave the
other window alone.  (BTW, using `delete-windows-on' for a frame showing
_one_ window is a kludge - but `delete-windows-on' is the only function
I found that handles some corner cases in this area correctly.)

> Why the condition-case only for delete-window?

I don't think it's needed.  But delete_window has a strange loop I never
understood completely which can err with "Cannot delete window" and I
wanted to avoid that.

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

That was already in the old version of `quit-window'.  Note that when
WINDOW is not the selected window, `bury-buffer' leaves the buffer
displayed in WINDOW.  `quit-window' must remove the buffer from WINDOW
even if WINDOW is not selected.

In any case, don't expect too much from `quit-window'.  The underlying
logic is too weak to make it more useful.  What we really need is a
buffer-local variable say `quit-windows-on' which, when set, triggers
some special code in `set-window-buffer' and `display-buffer'.  The
former would simply record in a window-local variable `how-to-quit' the
buffer formerly displayed in the window and `quit-window' could switch
to that buffer, provided its still live.

`display-buffer' would do the same but in addition, when it splits a
window to display the buffer, set `how-to-quit' to t so `quit-window'
could eventually delete that window.  A similar solution would have
`quit-window' delete a stand-alone frame popped up by `display-buffer'.

Most of this has been implemented in Lisp in some form or the other but
that's not sufficient.  `set-window-buffer' must act on this.

martin





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Juanma Barranquero" <lekktu <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #40 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Juanma Barranquero" <lekktu <at> gmail.com>
To: "martin rudalics" <rudalics <at> gmx.at>
Cc: 1259 <at> debbugs.gnu.org
Subject: quit-window does not kill the window
Date: Thu, 13 Nov 2008 17:40:55 +0100
Martin, I'm afraid I missed this comment by you:

"`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?"

But yes, it breaks one of my favorite uses.

The docstring previously said:

"If WINDOW is non-nil, it specifies a window; we delete that window,
and the buffer that is killed or buried is the one in that window."

Now, it says:

"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."

I was using the previously documented behavior. I have a function

(defun quit-buffer-and-window ()
   (interactive)
   (quit-window nil (selected-window)))

(I assign it to "q" in many modes). Now,

  C-x 2 C-x o M-x quit-buffer-and-window <ENTER>

leaves me with two windows.

  Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #45 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: quit-window does not kill the window
Date: Fri, 14 Nov 2008 09:06:36 +0100
> But yes, it breaks one of my favorite uses.
>
> The docstring previously said:
>
> "If WINDOW is non-nil, it specifies a window; we delete that window,
> and the buffer that is killed or buried is the one in that window."
>
> Now, it says:
>
> "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."
>
> I was using the previously documented behavior. I have a function
>
> (defun quit-buffer-and-window ()
>    (interactive)
>    (quit-window nil (selected-window)))
>
> (I assign it to "q" in many modes). Now,
>
>   C-x 2 C-x o M-x quit-buffer-and-window <ENTER>
>
> leaves me with two windows.

Sorry.  I apparently fail to understand what that function is supposed
to do.  Please try the version below and tell me whether it does what
you want.  If it still doesn't, then please try to write a doc-string so
I can implement what that doc-string says.

Thank you, martin.


(defun quit-window (&optional kill window)
  "Delete WINDOW and bury its buffer.
WINDOW defaults to the selected window.  Optional argument KILL
non-nil means kill WINDOW's buffer instead of burying it.

Always delete WINDOW if its frame contains at least one other
window.  If WINDOW is dedicated or a minibuffer window, and is
the only window on its frame, try to delete its frame too.  In
any other case, display another buffer in WINDOW."
  (interactive "P")
  (let* ((window (or window (selected-window)))
	 (buffer (window-buffer window)))
    (if (eq window (frame-root-window (window-frame window)))
	;; WINDOW is the only window on its frame.  `delete-windows-on'
	;; knows how to handle that particular case.
	(delete-windows-on buffer (selected-frame))
      ;; There are other windows left, delete just this window.  But
      ;; don't throw an error if that fails for some reason; rather
      ;; switch to another buffer instead.
      (condition-case nil
	  (delete-window window)
	(error (with-selected-window window
		 (switch-to-buffer nil)))))

    ;; Deal with the buffer.
    (if kill
	(kill-buffer buffer)
      (bury-buffer buffer))))





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Juanma Barranquero" <lekktu <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #50 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Juanma Barranquero" <lekktu <at> gmail.com>
To: "martin rudalics" <rudalics <at> gmx.at>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: quit-window does not kill the window
Date: Fri, 14 Nov 2008 10:19:26 +0100
On Fri, Nov 14, 2008 at 09:06, martin rudalics <rudalics <at> gmx.at> wrote:

> Sorry.  I apparently fail to understand what that function is supposed
> to do.

Truth be told, the docstring in 22.X wasn't very clear. The function
is called quit-window, but it talked about burying/killing the buffer,
and only off-handedly said:

"If window is non-nil, it specifies a window; we delete that window,
and the buffer that is killed or buried is the one in that window."

(Incidentally, that's the reason I defined quit-buffer-and-window in
the first place; with your changes, my function would be just an alias
for quit-window).

> Please try the version below and tell me whether it does what
> you want.

Yes, it works as expected now.

Thanks,

  Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Juanma Barranquero" <lekktu <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #55 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Juanma Barranquero" <lekktu <at> gmail.com>
To: "martin rudalics" <rudalics <at> gmx.at>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: quit-window does not kill the window
Date: Fri, 14 Nov 2008 10:36:00 +0100
On Fri, Nov 14, 2008 at 10:19, Juanma Barranquero <lekktu <at> gmail.com> wrote:

> Yes, it works as expected now.

To add more information: the difference in behavior between your
committed patch (let's call it v1) and the one you just sent (v2) is
related to defaulting to the selected window. I mean, with the
following defun

(defun my-quit-window ()
   (interactive)
   (quit-window nil (selected-window)))

and testing with

 emacs -Q
 C-h N
 M-x occur <ENTER> emacs <ENTER>
 C-x o
 M-x quit-window <ENTER>  ;; or M-x my-quit-window <ENTER>

In 22.X:

  M-x quit-window    => buries the buffer, keeps the window
  M-x my-quit-window => buries the buffer, kills the window

In 23.X, v1

  M-x quit-window    => buries the buffer, keeps the window
  M-x my-quit-window => buries the buffer, keeps the window

In 23.X, v2

  M-x quit-window    => buries the buffer, kills the window
  M-x my-quit-window => buries the buffer, kills the window

So, basically the original `quit-window' had two different behaviors,
while your patches just have one.

Personally, I'm happy with the "kills the window" behavior, so v2
works for me. But perhaps other people expects quit-window to behave
as it did in 22.X.

  Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #60 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: quit-window does not kill the window
Date: Fri, 14 Nov 2008 14:41:07 +0100
> In 22.X:
>
>   M-x quit-window    => buries the buffer, keeps the window
[...]
> In 23.X, v1
>
>   M-x quit-window    => buries the buffer, keeps the window
[...]

Thanks for investigating this.  I was to silly to figure it out.

Deleting the window iff it's explicitly specified strikes me as
non-intuitive.  Anyway, the version below should do that.

Please give it another try.

And thanks again for the explanations, martin.


(defun quit-window (&optional kill window)
  "Quit WINDOW and bury or kill its buffer.
WINDOW defaults to the selected window.

If WINDOW is dedicated or a minibuffer window, delete WINDOW and,
if it's alone on its frame, its frame too.  Else, if WINDOW was
explicitly specified and not nil, delete it.  Otherwise, or if
deleting WINDOW fails in any of the preceding cases, display
another buffer in WINDOW using `switch-to-buffer'.

Optional argument KILL non-nil means kill WINDOW's buffer.
Otherwise, bury WINDOW's buffer, see `bury-buffer'."
  (interactive "P")
  ;; Don't let-bind WINDOW here; below we want to know whether the
  ;; WINDOW argument was explictly specified.
  (let* ((window-to-handle (or window (selected-window)))
	 (buffer (window-buffer window-to-handle)))
    (cond
     ((or (window-minibuffer-p window-to-handle)
	  (window-dedicated-p window-to-handle))
      ;; Minibuffer windows and dedicated windows are treated specially.
      (let ((frame (window-frame window-to-handle)))
	(if (eq window-to-handle (frame-root-window frame))
	    ;; The window to handle is alone on its frame.
	    ;; `delete-windows-on' knows what to do.
	    (delete-windows-on buffer frame)
	  ;; There are other windows on the frame, delete this one.
	  (delete-window window-to-handle))))
     ((not window)
      ;; No WINDOW was specified.  Switch to another buffer in the
      ;; selected window.
      (switch-to-buffer nil))
     (t
      ;; WINDOW was specified, try to delete it.  But don't throw an
      ;; error if that fails; rather switch to another buffer instead.
      (condition-case nil
	  (delete-window window-to-handle)
	(error (with-selected-window window-to-handle
		 (switch-to-buffer nil))))))

    ;; Deal with the buffer.
    (if kill
	(kill-buffer buffer)
      (bury-buffer buffer))))





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Juanma Barranquero" <lekktu <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #65 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Juanma Barranquero" <lekktu <at> gmail.com>
To: "martin rudalics" <rudalics <at> gmx.at>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: bug#1259: quit-window does not kill the window
Date: Fri, 14 Nov 2008 16:10:26 +0100
On Fri, Nov 14, 2008 at 14:41, martin rudalics <rudalics <at> gmx.at> wrote:

> Deleting the window iff it's explicitly specified strikes me as
> non-intuitive.

I think quit-window conflates two interfaces, one for humans that does
not kill the window, and another for elisp that allows killing it;
that second interface does not need to be "interactively intuitive",
but certainly is not illogical (the programmer is taking the pain to
explicitly pass a window instead of using the default, after all). I
just happened to be using interactively the second interface.

> Anyway, the version below should do that.
>
> Please give it another try.

It works as expected now for quit-window and my-quit-window.

I've only tested my common use of the function, though: single frame,
one window (plus the one killed by quit-window).

Thanks for fixing this,

  Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #70 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: gnu-emacs-bug <at> moderators.isc.org
Subject: Re: bug#1259: quit-window does not kill the window
Date: Fri, 14 Nov 2008 18:03:06 +0100
martin rudalics <rudalics <at> gmx.at> writes:

> Optional argument KILL non-nil means kill WINDOW's buffer.
> Otherwise, bury WINDOW's buffer, see `bury-buffer'."

Could you please mention the meaning of a prefix argument in interactive
use again? Previously, the docstring included the now missing sentence:

   With a prefix argument, kill the buffer instead.

C-u q is a great feature in many modes (doc-view-mode, image-mode etc.),
because it does not ask for which buffer to kill (in contrast to C-x k),
so I hope it remains available and documented. Thank you in advance!





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #75 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: bug#1259: quit-window does not kill the window
Date: Sat, 15 Nov 2008 11:00:10 +0100
> It works as expected now for quit-window and my-quit-window.

I checked in a simpler version.  Could you try once more?

martin




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #80 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Markus Triska <markus.triska <at> gmx.at>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: bug#1259: quit-window does not kill the window
Date: Sat, 15 Nov 2008 11:00:15 +0100
> Could you please mention the meaning of a prefix argument in interactive
> use again? Previously, the docstring included the now missing sentence:
> 
>    With a prefix argument, kill the buffer instead.

It's there again.

martin





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1259; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Juanma Barranquero" <lekktu <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #85 received at 1259 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Juanma Barranquero" <lekktu <at> gmail.com>
To: "martin rudalics" <rudalics <at> gmx.at>
Cc: 1259 <at> debbugs.gnu.org
Subject: Re: bug#1259: quit-window does not kill the window
Date: Sat, 15 Nov 2008 12:22:41 +0100
On Sat, Nov 15, 2008 at 11:00, martin rudalics <rudalics <at> gmx.at> wrote:

> I checked in a simpler version.  Could you try once more?

Yes, it works as expected.

Thanks,

             Juanma




bug archived. Request was from Debbugs Internal Request <don <at> donarmstrong.com> to internal_control <at> emacsbugs.donarmstrong.com. (Sat, 13 Dec 2008 15:24:05 GMT) Full text and rfc822 format available.

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.