]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/lisp.el
(find-definition-noselect): Fix typo in a doc string: "functoin" => "function".
[gnu-emacs] / lisp / emacs-lisp / lisp.el
index 7aeb33a648e1c83501d8a23d1c029675d830b132..30505c95223a6761f64eb4870cdf499c3be018bd 100644 (file)
@@ -569,28 +569,37 @@ considered."
              ((null completion)
               (message "Can't find completion for \"%s\"" pattern)
               (ding))
+             ((not (string= pattern completion))
+              (delete-region beg end)
+              (insert completion)
+              ;; Don't leave around a completions buffer that's out of date.
+              (let ((win (get-buffer-window "*Completions*" 0)))
+                (if win (with-selected-window win (bury-buffer)))))
              (t
-              (unless (string= completion pattern)
-                (delete-region beg end)
-                (insert completion)
-                (setq pattern completion))
-              (message "Making completion list...")
-              (let ((list (all-completions pattern obarray predicate)))
-                (setq list (sort list 'string<))
-                (or (eq predicate 'fboundp)
-                    (let (new)
-                      (while list
-                        (setq new (cons (if (fboundp (intern (car list)))
-                                            (list (car list) " <f>")
-                                          (car list))
-                                        new))
-                        (setq list (cdr list)))
-                      (setq list (nreverse new))))
-                (if (> (length list) 1)
-                    (with-output-to-temp-buffer "*Completions*"
-                      (display-completion-list list pattern))
-                  (delete-windows-on "*Completions*")))
-              (message "Making completion list...%s" "done")))))))
-
-;;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e
+              (let ((minibuf-is-in-use
+                     (eq (minibuffer-window) (selected-window))))
+                (unless minibuf-is-in-use
+                  (message "Making completion list..."))
+                (let ((list (all-completions pattern obarray predicate)))
+                  (setq list (sort list 'string<))
+                  (or (eq predicate 'fboundp)
+                      (let (new)
+                        (while list
+                          (setq new (cons (if (fboundp (intern (car list)))
+                                              (list (car list) " <f>")
+                                            (car list))
+                                          new))
+                          (setq list (cdr list)))
+                        (setq list (nreverse new))))
+                  (if (> (length list) 1)
+                      (with-output-to-temp-buffer "*Completions*"
+                        (display-completion-list list pattern))
+                    ;; Don't leave around a completions buffer that's
+                    ;; out of date.
+                    (let ((win (get-buffer-window "*Completions*" 0)))
+                      (if win (with-selected-window win (bury-buffer))))))
+                (unless minibuf-is-in-use
+                  (message "Making completion list...%s" "done")))))))))
+
+;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e
 ;;; lisp.el ends here