changeset 106132:57f23ca20a76

* window.el (display-buffer-mark-dedicated): New var. (display-buffer): Obey it. * minibuffer.el (minibuffer-completion-help): Use it.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 19 Nov 2009 22:05:40 +0000
parents aef9a4af6024
children 5e6998ac1a2e
files lisp/ChangeLog lisp/minibuffer.el lisp/window.el
diffstat 3 files changed, 30 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Nov 19 22:03:36 2009 +0000
+++ b/lisp/ChangeLog	Thu Nov 19 22:05:40 2009 +0000
@@ -1,5 +1,9 @@
 2009-11-19  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* window.el (display-buffer-mark-dedicated): New var.
+	(display-buffer): Obey it.
+	* minibuffer.el (minibuffer-completion-help): Use it.
+
 	* progmodes/sym-comp.el (symbol-complete): Use completion-in-region.
 
 	* filecache.el (file-cache-add-file): Use push and cons.
--- a/lisp/minibuffer.el	Thu Nov 19 22:03:36 2009 +0000
+++ b/lisp/minibuffer.el	Thu Nov 19 22:05:40 2009 +0000
@@ -1004,9 +1004,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)))
+        (let* ((last (last completions))
+               (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))
@@ -1019,11 +1024,11 @@
                                 (if ann (list s ann) s)))
                             completions)))
             (with-current-buffer standard-output
-	      (set (make-local-variable 'completion-base-position)
-		   ;; FIXME: We should provide the END part as well, but
-		   ;; currently completion-all-completions does not give
-		   ;; us the necessary information.
-		   (list (+ start base-size) nil)))
+              (set (make-local-variable 'completion-base-position)
+                   ;; FIXME: We should provide the END part as well, but
+                   ;; currently completion-all-completions does not give
+                   ;; us the necessary information.
+                   (list (+ start base-size) nil)))
             (display-completion-list completions)))
 
       ;; If there are no completions, or if the current input is already the
--- a/lisp/window.el	Thu Nov 19 22:03:36 2009 +0000
+++ b/lisp/window.el	Thu Nov 19 22:05:40 2009 +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 +1138,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 +1156,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