diff --git a/lisp/simple.el b/lisp/simple.el index 12435a0680..fd17749451 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8850,10 +8850,12 @@ next-completion (point) 'mouse-face nil beg)) (setq n (1+ n)))))) -(defun choose-completion (&optional event) +(defun choose-completion (&optional event arg) "Choose the completion at point. -If EVENT, use EVENT's position to determine the starting position." - (interactive (list last-nonmenu-event)) +If EVENT, use EVENT's position to determine the starting position. +When the prefix ARG is 0, insert the completion at point to the minibuffer +and quit the completion window without exiting the minibuffer." + (interactive (list last-nonmenu-event current-prefix-arg)) ;; In case this is run via the mouse, give temporary modes such as ;; isearch a chance to turn off. (run-hooks 'mouse-leave-buffer-hook) @@ -8861,6 +8863,7 @@ choose-completion (let ((buffer completion-reference-buffer) (base-position completion-base-position) (insert-function completion-list-insert-choice-function) + (completion-no-auto-exit (if (eq arg 0) t completion-no-auto-exit)) (choice (save-excursion (goto-char (posn-point (event-start event)))