all messages for Emacs-related lists mirrored at yhetil.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 11:31:47 +0100	[thread overview]
Message-ID: <49059893.3020006@gmx.at> (raw)
In-Reply-To: <E42FC1D6-A191-475C-88BD-F9FA2C50C78B@gmail.com>

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







  reply	other threads:[~2008-10-27 10:31 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 [this message]
2008-10-27 15:01     ` David Reitter
2008-10-27 17:07       ` martin rudalics
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

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

  git send-email \
    --in-reply-to=49059893.3020006@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 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.