Function: icomplete-force-complete-and-exit

icomplete-force-complete-and-exit is an interactive and byte-compiled function defined in icomplete.el.gz.

Signature

(icomplete-force-complete-and-exit)

Documentation

Complete the minibuffer with the longest possible match and exit.

Use the first of the matches if there are any displayed, and use the default otherwise.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/icomplete.el.gz
(defun icomplete-force-complete-and-exit ()
  "Complete the minibuffer with the longest possible match and exit.
Use the first of the matches if there are any displayed, and use
the default otherwise."
  (interactive)
  ;; This function is tricky.  The mandate is to "force", meaning we
  ;; should take the first possible valid completion for the input.
  ;; However, if there is no input and we can prove that that
  ;; coincides with the default, it is much faster to just call
  ;; `minibuffer-complete-and-exit'.  Otherwise, we have to call
  ;; `minibuffer-force-complete-and-exit', which needs the full
  ;; completion set and is potentially slow and blocking.  Do the
  ;; latter if:
  (if (or
       ;; there's some input, meaning the default in off the table by
       ;; definition; OR
       (not (equal (icomplete--field-string) icomplete--initial-input))
       ;; there's no input, but there's also no minibuffer default
       ;; (and the user really wants to see completions on no input,
       ;; meaning he expects a "force" to be at least attempted); OR
       (and (not minibuffer-default)
            icomplete-show-matches-on-no-input)
       ;; there's no input but the full completion set has been
       ;; calculated, This causes the first cached completion to
       ;; be taken (i.e. the one that the user sees highlighted)
       completion-all-sorted-completions)
      (if (window-minibuffer-p)
          (minibuffer-force-complete-and-exit)
        (minibuffer-force-complete (icomplete--field-beg)
                                   (icomplete--field-end)
                                   'dont-cycle)
        (completion-in-region-mode -1))
    ;; Otherwise take the faster route...
    (if (window-minibuffer-p)
        (minibuffer-complete-and-exit)
      (completion-complete-and-exit
       (icomplete--field-beg)
       (icomplete--field-end)
       (lambda () (completion-in-region-mode -1))))))