all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Juanma Barranquero <lekktu@gmail.com>
Cc: 1259@emacsbugs.donarmstrong.com
Subject: bug#1259: quit-window does not kill the window
Date: Fri, 14 Nov 2008 14:41:07 +0100	[thread overview]
Message-ID: <491D7FF3.4050507@gmx.at> (raw)
In-Reply-To: <f7ccd24b0811140136p31208c8csb21a21b70b6bf2a1@mail.gmail.com>

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







  reply	other threads:[~2008-11-14 13:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-13 16:40 bug#1259: quit-window does not kill the window Juanma Barranquero
2008-11-14  8:06 ` martin rudalics
2008-11-14  9:19   ` Juanma Barranquero
2008-11-14  9:36     ` Juanma Barranquero
2008-11-14 13:41       ` martin rudalics [this message]
2008-11-14 15:10         ` Juanma Barranquero
2008-11-15 10:00           ` martin rudalics
2008-11-15 11:22             ` Juanma Barranquero
     [not found]       ` <mailman.353.1226670617.26697.bug-gnu-emacs@gnu.org>
2008-11-14 17:03         ` Markus Triska
2008-11-15 10:00           ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=491D7FF3.4050507@gmx.at \
    --to=rudalics@gmx.at \
    --cc=1259@emacsbugs.donarmstrong.com \
    --cc=lekktu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.