# HG changeset patch # User Richard M. Stallman # Date 768115679 0 # Node ID 7a0395228878772ac69e89e8e6f1c68657e41cae # Parent e30a34bfc5369a016281f6546648b3b73ec27484 (choose-completion-string): Barf if completing into a minibuffer but it's not now active. diff -r e30a34bfc536 -r 7a0395228878 lisp/simple.el --- a/lisp/simple.el Thu May 05 05:08:57 1994 +0000 +++ b/lisp/simple.el Thu May 05 05:27:59 1994 +0000 @@ -2461,14 +2461,22 @@ (defun choose-completion-string (choice &optional buffer) (let ((buffer (or buffer completion-reference-buffer))) - (set-buffer buffer) - (choose-completion-delete-max-match choice) - (insert choice) - ;; Update point in the window that BUFFER is showing in. - (let ((window (get-buffer-window buffer t))) - (set-window-point window (point))) - (and (equal buffer (window-buffer (minibuffer-window))) - (minibuffer-complete-and-exit)))) + ;; If BUFFER is a minibuffer, barf unless it's the currently + ;; active minibuffer. + (if (and (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer)) + (or (not (minibuffer-window-active-p (minibuffer-window))) + (not (equal buffer (window-buffer (minibuffer-window)))))) + (error "Minibuffer is not active for completion") + ;; Insert the completion into the buffer where completion was requested. + (set-buffer buffer) + (choose-completion-delete-max-match choice) + (insert choice) + ;; Update point in the window that BUFFER is showing in. + (let ((window (get-buffer-window buffer t))) + (set-window-point window (point))) + ;; If completing for the minibuffer, exit it with this choice. + (and (equal buffer (window-buffer (minibuffer-window))) + (minibuffer-complete-and-exit))))) (defun completion-list-mode () "Major mode for buffers showing lists of possible completions.