From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: undisplay temporary dialog buffers when done [was: ... dedicated windows and popup frames] Date: Sun, 10 Jul 2011 16:45:26 -0700 Message-ID: <1C868A007F33466FA852C4589C08B139@us.oracle.com> References: <871uy0n9ch.fsf@member.fsf.org> <8762nc8xqe.fsf@member.fsf.org><4E185100.2050100@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1310341571 762 80.91.229.12 (10 Jul 2011 23:46:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 10 Jul 2011 23:46:11 +0000 (UTC) Cc: 'Tassilo Horn' , emacs-devel@gnu.org To: "'martin rudalics'" , "'Stefan Monnier'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 11 01:46:05 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Qg3hN-00024D-0b for ged-emacs-devel@m.gmane.org; Mon, 11 Jul 2011 01:46:05 +0200 Original-Received: from localhost ([::1]:53419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qg3hM-0005Lp-0Z for ged-emacs-devel@m.gmane.org; Sun, 10 Jul 2011 19:46:04 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:50522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qg3h7-0005Li-NV for emacs-devel@gnu.org; Sun, 10 Jul 2011 19:45:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qg3h6-0000LR-Nb for emacs-devel@gnu.org; Sun, 10 Jul 2011 19:45:49 -0400 Original-Received: from rcsinet15.oracle.com ([148.87.113.117]:28373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qg3h6-0000LI-IN for emacs-devel@gnu.org; Sun, 10 Jul 2011 19:45:48 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p6ANjfIL006303 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 10 Jul 2011 23:45:43 GMT Original-Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p6ANjeON011274 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 10 Jul 2011 23:45:40 GMT Original-Received: from abhmt114.oracle.com (abhmt114.oracle.com [141.146.116.66]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p6ANjZT4023668; Sun, 10 Jul 2011 18:45:35 -0500 Original-Received: from dradamslap1 (/10.159.32.168) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 10 Jul 2011 16:45:34 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: Acw+OEj0rKfOtgkiRrmAonfeRBa4cQACmt4gADtsl+A= X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090206.4E1A39A7.00B4:SCFMA922111,ss=1,re=-4.000,fgs=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 148.87.113.117 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:141925 Archived-At: For code that temporarily displays a buffer for the duration of a user-input dialog, I suggested that we might wrap that code, so that when the dialog is finished the buffer's display disappears: it is undisplayed as part of unwinding the dialog. This pertains to buffer displays such as *Completions* and the Dired marked-files list (e.g. when you delete, copy, etc. files). Such buffers are popped up in a window that might be dedicated, in a separate frame, etc., depending on user settings. We generally want to get rid of the buffer's display in such cases. This was the suggestion: > Perhaps we could add a way for code to indicate that it is > displaying a given buffer only for the purpose and duration > of a user dialog, and thus: > > a. For that duration the buffer's frame (if separate) would > have its input focus redirected to the minibuffer's frame. > b. After the dialog finishes, the buffer's frame (if > separate) would be deleted. > > E.g., something like: (with-dialog-buffer BUF ...) > Perhaps something like that could be a way to handle the > general case (providing that coders actually used it). This approach gives the code that carries out the user-input dialog and displays the supporting information buffer the responsibility and possibility of making that buffer disappear when the dialog is over. IOW, it keeps control over such behavior local to where it is needed. Here is an example of what I meant by such a macro (not tested much). Instead of `with-dialog-buffer' I named it `undisplay-on-unwind'. It need not be associated with dialog code, but that is probably the typical case. (defmacro undisplay-on-unwind (buffer &rest body) "Undisplay BUFFER after evaluating BODY. If BUFFER is not shown in the selected window or `minibuffer-selected-window', then bury BUFFER (`bury-buffer') and delete all windows showing it, if possible. Use this in particular when BODY pops up BUFFER as part of a temporary dialog and there is no need to show BUFFER after the dialog is finished." (let ((buf (make-symbol "buf"))) `(unwind-protect (progn ,@body) (let ((,buf ,buffer)) (when (bufferp ,buf) (setq ,buf (buffer-name ,buf))) (when (stringp ,buf) (let ((swin (selected-window))) ;; Do nothing if BUFFER is in the selected window ;; or the minibuffer window is selected now ;; and BUFFER's window was selected just before. (when (window-minibuffer-p swin) (setq swin (minibuffer-selected-window))) (when (and (get-buffer-window ,buf 'visible) (window-live-p swin) ; Needed? (not (eq (window-buffer swin) (get-buffer ,buf)))) ;; Ignore, in particular, "Attempt to delete ;; the sole visible or iconified frame". (ignore-errors (delete-windows-on ,buf)) (bury-buffer (get-buffer ,buf))))))))) This is adapted from part of how I treat `*Completions*' in Icicles. The point here is to give an idea of what such a macro might be - I don't argue that this particular implementation is necessarily correct, complete, what we want, etc. The idea is to couple (a) the display of a buffer whose only purpose is to provide info for some input dialog with (b) that dialog. The BODY for the macro would typically be code that displays BUFFER and asks for some user input. After that dialog is finished, we remove all display of BUFFER. You can try it a bit. E.g.: (defun bar (f1 &optional f2) (let ((foo (get-buffer-create "*FOO*"))) (with-current-buffer foo (erase-buffer)(insert "HHHHHHHHHHHHHHHHHHHHHHHHHHHH")) (funcall f1 foo) (when f2 (save-selected-window (select-window (get-buffer-window "*FOO*" 'visible)) (funcall f2 foo)))) (redisplay t)(sleep-for 3)) ;; 1. Show *FOO* in a separate window (by default). (undisplay-on-unwind "*FOO*" (bar 'display-buffer)) ;; 2. Like previous, but with *FOO* in a separate frame. (undisplay-on-unwind "*FOO*" (bar 'display-buffer-other-frame)) Those two represent the typical case, but we can imagine that `*FOO*' might be displayed in more than one window. ;; 3. Like previous, but two *FOO*s, one in a separate frame. (undisplay-on-unwind "*FOO*" (bar 'display-buffer 'display-buffer-other-frame)) ;; 4. Like previous, but won't delete the frame ;; from `make-frame-command'. (undisplay-on-unwind "*FOO*" (bar 'display-buffer '(lambda (f) (make-frame-command))))