changeset 76349:df0cc74b8778

(pcomplete-show-completions): Improve last change, so as not to use an invisible window and to create a window if none exist.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 05 Mar 2007 19:57:10 +0000
parents 05d93f5e8286
children afaae6720920
files lisp/pcomplete.el
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/pcomplete.el	Mon Mar 05 19:57:03 2007 +0000
+++ b/lisp/pcomplete.el	Mon Mar 05 19:57:10 2007 +0000
@@ -974,18 +974,20 @@
 	    (while (with-current-buffer (get-buffer "*Completions*")
 		     (setq event (pcomplete-read-event)))
 	      (cond
-	       ((event-matches-key-specifier-p event ? )
+	       ((event-matches-key-specifier-p event ?\s)
 		(set-window-configuration pcomplete-last-window-config)
 		(setq pcomplete-last-window-config nil)
 		(throw 'done nil))
 	       ((or (event-matches-key-specifier-p event 'tab)
                     ;; Needed on a terminal
                     (event-matches-key-specifier-p event 9))
-		(save-selected-window
-		  (select-window (get-buffer-window "*Completions*" t))
-		  (if (pos-visible-in-window-p (point-max))
-		      (goto-char (point-min))
-		    (scroll-up)))
+                (let ((win (or (get-buffer-window "*Completions*" 0)
+                               (display-buffer "*Completions*"
+                                               'not-this-window))))
+                  (with-selected-window win
+                    (if (pos-visible-in-window-p (point-max))
+                        (goto-char (point-min))
+                      (scroll-up))))
 		(message ""))
 	       (t
 		(setq unread-command-events (list event))