Function: choose-completion
choose-completion is an interactive and byte-compiled function defined
in simple.el.gz.
Signature
(choose-completion &optional EVENT)
Documentation
Choose the completion at point.
If EVENT, use EVENT's position to determine the starting position.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun choose-completion (&optional event)
"Choose the completion at point.
If EVENT, use EVENT's position to determine the starting position."
(interactive (list last-nonmenu-event))
;; 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)
(with-current-buffer (window-buffer (posn-window (event-start event)))
(let ((buffer completion-reference-buffer)
(base-position completion-base-position)
(insert-function completion-list-insert-choice-function)
(choice
(save-excursion
(goto-char (posn-point (event-start event)))
(let (beg)
(cond
((and (not (eobp)) (get-text-property (point) 'mouse-face))
(setq beg (1+ (point))))
((and (not (bobp))
(get-text-property (1- (point)) 'mouse-face))
(setq beg (point)))
(t (error "No completion here")))
(setq beg (previous-single-property-change beg 'mouse-face))
(substring-no-properties
(get-text-property beg 'completion--string))))))
(unless (buffer-live-p buffer)
(error "Destination buffer is dead"))
(quit-window nil (posn-window (event-start event)))
(with-current-buffer buffer
(choose-completion-string
choice buffer
(or base-position
;; If all else fails, just guess.
(list (choose-completion-guess-base-position choice)))
insert-function)))))