From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#1259: quit-window does not kill the window Date: Fri, 14 Nov 2008 14:41:07 +0100 Message-ID: <491D7FF3.4050507@gmx.at> References: <491D318C.80402@gmx.at> Reply-To: martin rudalics , 1259@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1226670682 6903 80.91.229.12 (14 Nov 2008 13:51:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Nov 2008 13:51:22 +0000 (UTC) Cc: 1259@emacsbugs.donarmstrong.com To: Juanma Barranquero Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 14 14:52:22 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L0z5s-0001V8-SQ for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Nov 2008 14:52:17 +0100 Original-Received: from localhost ([127.0.0.1]:43821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0z4k-0003Si-Hu for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Nov 2008 08:51:06 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0z3v-0003IM-CF for bug-gnu-emacs@gnu.org; Fri, 14 Nov 2008 08:50:15 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0z3r-0003HM-F5 for bug-gnu-emacs@gnu.org; Fri, 14 Nov 2008 08:50:13 -0500 Original-Received: from [199.232.76.173] (port=44853 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0z3q-0003H7-SB for bug-gnu-emacs@gnu.org; Fri, 14 Nov 2008 08:50:11 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:55581) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L0z3q-0000hk-MK for bug-gnu-emacs@gnu.org; Fri, 14 Nov 2008 08:50:11 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mAEDo7jv032597; Fri, 14 Nov 2008 05:50:08 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id mAEDo3F4032311; Fri, 14 Nov 2008 05:50:03 -0800 X-Loop: don@donarmstrong.com Resent-From: martin rudalics Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 14 Nov 2008 13:50:03 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1259 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 1259-submit@emacsbugs.donarmstrong.com id=B1259.122667021430987 (code B ref 1259); Fri, 14 Nov 2008 13:50:03 +0000 Original-Received: (at 1259) by emacsbugs.donarmstrong.com; 14 Nov 2008 13:43:34 +0000 Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with SMTP id mAEDhUMM030974 for <1259@emacsbugs.donarmstrong.com>; Fri, 14 Nov 2008 05:43:31 -0800 Original-Received: (qmail invoked by alias); 14 Nov 2008 13:43:23 -0000 Original-Received: from 88-117-34-6.adsl.highway.telekom.at (EHLO [88.117.34.6]) [88.117.34.6] by mail.gmx.net (mp026) with SMTP; 14 Nov 2008 14:43:23 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX19JV3AN1lJJPxXvyzDaNZpYsbof21xWfrW5rcja7O EmSM1jLJHUb8qQ User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) In-Reply-To: X-Y-GMX-Trusted: 0 X-FuHaFi: 0.6 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Fri, 14 Nov 2008 08:50:13 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:22337 Archived-At: > 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))))