unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: David Reitter <david.reitter@gmail.com>
Cc: 1259@emacsbugs.donarmstrong.com
Subject: bug#1259: quit-window: does it quit the wrong buffer?
Date: Mon, 27 Oct 2008 18:07:36 +0100	[thread overview]
Message-ID: <4905F558.7070005@gmx.at> (raw)
In-Reply-To: <4757158C-5312-498F-94C6-7A34C0BEFC59@gmail.com>

`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	other threads:[~2008-10-27 17:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4909D5D9.60300@gmx.at>
2008-10-27  1:19 ` bug#1259: quit-window: does it quit the wrong buffer? David Reitter
2008-10-27 10:31   ` martin rudalics
2008-10-27 15:01     ` David Reitter
2008-10-27 17:07       ` martin rudalics [this message]
2008-11-04 17:40         ` David Reitter
2008-11-04 18:15           ` martin rudalics
2008-10-30 15:50   ` bug#1259: marked as done (quit-window: does it quit the wrong buffer?) Emacs bug Tracking System

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=4905F558.7070005@gmx.at \
    --to=rudalics@gmx.at \
    --cc=1259@emacsbugs.donarmstrong.com \
    --cc=david.reitter@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).