From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#4914: completions - remove window after use? Date: Tue, 17 Nov 2009 18:00:31 -0500 Message-ID: References: <61C01A08-8FB6-4908-B9F1-B9F1CE3E3D92@gmail.com> <4AFBC50D.1060007@gmx.at> <6B8057CC-08E3-4A6F-BDCC-0A8CBD738365@gmail.com> <4AFC4889.6090707@gmx.at> <22B10138-7AD6-4138-BD23-DA62D9B79BCB@gmail.com> <4AFC6176.3010306@gmx.at> Reply-To: Stefan Monnier , 4914@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1258500462 26778 80.91.229.12 (17 Nov 2009 23:27:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 17 Nov 2009 23:27:42 +0000 (UTC) Cc: 4914@emacsbugs.donarmstrong.com, David Reitter To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 18 00:27:35 2009 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 1NAXSP-0003Cf-Tm for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Nov 2009 00:27:34 +0100 Original-Received: from localhost ([127.0.0.1]:60936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAXSP-0006dH-6T for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Nov 2009 18:27:33 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NAXSK-0006cu-Ra for bug-gnu-emacs@gnu.org; Tue, 17 Nov 2009 18:27:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NAXSG-0006YA-42 for bug-gnu-emacs@gnu.org; Tue, 17 Nov 2009 18:27:28 -0500 Original-Received: from [199.232.76.173] (port=48121 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAXSF-0006Y4-W4 for bug-gnu-emacs@gnu.org; Tue, 17 Nov 2009 18:27:24 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:47140) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NAXSF-0003Hd-F6 for bug-gnu-emacs@gnu.org; Tue, 17 Nov 2009 18:27:23 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAHNRKIj002350; Tue, 17 Nov 2009 15:27:21 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nAHNA4HT000779; Tue, 17 Nov 2009 15:10:04 -0800 Resent-Date: Tue, 17 Nov 2009 15:10:04 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Tue, 17 Nov 2009 23:10:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4914 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 4914-submit@emacsbugs.donarmstrong.com id=B4914.125849883831913 (code B ref 4914); Tue, 17 Nov 2009 23:10:04 +0000 Original-Received: (at 4914) by emacsbugs.donarmstrong.com; 17 Nov 2009 23:00:38 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from chene.dit.umontreal.ca (chene.dit.umontreal.ca [132.204.246.20]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAHN0YdY031910 for <4914@emacsbugs.donarmstrong.com>; Tue, 17 Nov 2009 15:00:36 -0800 Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id nAHN0Wei024554; Tue, 17 Nov 2009 18:00:32 -0500 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id E4A393A0FA; Tue, 17 Nov 2009 18:00:31 -0500 (EST) In-Reply-To: <4AFC6176.3010306@gmx.at> (martin rudalics's message of "Thu, 12 Nov 2009 20:26:46 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3408=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Tue, 17 Nov 2009 18:27:28 -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:32676 Archived-At: >> That would be good. Quite generally, those windows/frames that are >> created (e.g. via pop-to-buffer) for a specific window should be >> removed after we're done with the interaction (see also quit-window). >> I've had a kludge for this in Aquamacs for a long time (via an advice >> to bury-buffer), but it's quite difficult to do consistently when >> Emacs and 3rd-part packages aren't aware that this is happening. > It's practically impossible to find a solution that satisfies all needs > in this area. Basically, `display-buffer' would set a special slot for > any window it pops up and `quit-window' would try to delete a window if > it has that slot set and still shows the argument of `display-buffer'. How 'bout the patch below? Stefan "whose .emacs would have (setq display-buffer-mark-dedicated 'soft)" Index: lisp/minibuffer.el =================================================================== RCS file: /sources/emacs/emacs/lisp/minibuffer.el,v retrieving revision 1.96 diff -u -r1.96 minibuffer.el --- lisp/minibuffer.el 12 Nov 2009 23:10:06 -0000 1.96 +++ lisp/minibuffer.el 17 Nov 2009 22:56:12 -0000 @@ -965,9 +965,14 @@ (if (and completions (or (consp (cdr completions)) (not (equal (car completions) string)))) - (with-output-to-temp-buffer "*Completions*" (let* ((last (last completions)) - (base-size (cdr last))) + (base-size (cdr last)) + ;; If the *Completions* buffer is shown in a new + ;; window, mark it as softly-dedicated, so bury-buffer in + ;; minibuffer-hide-completions will know whether to + ;; delete the window or not. + (display-buffer-mark-dedicated 'soft)) + (with-output-to-temp-buffer "*Completions*" ;; Remove the base-size tail because `sort' requires a properly ;; nil-terminated list. (when last (setcdr last nil)) Index: lisp/window.el =================================================================== RCS file: /sources/emacs/emacs/lisp/window.el,v retrieving revision 1.185 diff -u -r1.185 window.el --- lisp/window.el 13 Nov 2009 22:19:56 -0000 1.185 +++ lisp/window.el 17 Nov 2009 22:56:12 -0000 @@ -1042,6 +1042,11 @@ (set-window-buffer window buffer) (window--display-buffer-1 window))) +(defvar display-buffer-mark-dedicated nil + "If non-nil, `display-buffer' marks the windows it creates as dedicated. +The actual non-nil value of this variable will be copied to the +`window-dedicated-p' flag.") + (defun display-buffer (buffer-or-name &optional not-this-window frame) "Make buffer BUFFER-OR-NAME appear in some window but don't select it. BUFFER-OR-NAME must be a buffer or the name of an existing @@ -1133,8 +1133,10 @@ buffer (if (listp pars) pars)))))) ((or use-pop-up-frames (not frame-to-use)) ;; We want or need a new frame. - (window--display-buffer-2 - buffer (frame-selected-window (funcall pop-up-frame-function)))) + (let ((win (frame-selected-window (funcall pop-up-frame-function)))) + (when display-buffer-mark-dedicated + (set-window-dedicated-p win display-buffer-mark-dedicated)) + (window--display-buffer-2 buffer win))) ((and pop-up-windows ;; Make a new window. (or (not (frame-parameter frame-to-use 'unsplittable)) @@ -1149,8 +1149,10 @@ (or (window--try-to-split-window (get-largest-window frame-to-use t)) (window--try-to-split-window - (get-lru-window frame-to-use t)))) - (window--display-buffer-2 buffer window-to-use))) + (get-lru-window frame-to-use t))))) + (when display-buffer-mark-dedicated + (set-window-dedicated-p window-to-use display-buffer-mark-dedicated)) + (window--display-buffer-2 buffer window-to-use)) ((let ((window-to-undedicate ;; When NOT-THIS-WINDOW is non-nil, temporarily dedicate ;; the selected window to its buffer, to avoid that some of