# HG changeset patch # User Stefan Monnier # Date 1173124630 0 # Node ID df0cc74b8778d79276af392a0a529eed6cb8476a # Parent 05d93f5e8286108b51bb46c9e4b64a95cad92a12 (pcomplete-show-completions): Improve last change, so as not to use an invisible window and to create a window if none exist. diff -r 05d93f5e8286 -r df0cc74b8778 lisp/pcomplete.el --- 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))