Function: icomplete-exhibit

icomplete-exhibit is a byte-compiled function defined in icomplete.el.gz.

Signature

(icomplete-exhibit)

Documentation

Insert Icomplete completions display.

Should be run via minibuffer post-command-hook. See icomplete-mode(var)/icomplete-mode(fun) and minibuffer-setup-hook.

Source Code

;; Defined in /usr/src/emacs/lisp/icomplete.el.gz
;;;_* Completion

;;;_ > icomplete-exhibit ()
(defun icomplete-exhibit ()
  "Insert Icomplete completions display.
Should be run via minibuffer `post-command-hook'.
See `icomplete-mode' and `minibuffer-setup-hook'."
  (when (and icomplete-mode
             ;; Check if still in the right buffer (bug#61308)
             (or (window-minibuffer-p) completion-in-region--data)
             (icomplete-simple-completing-p)) ;Shouldn't be necessary.
    (let ((saved-point (point))
          (completion-lazy-hilit t))
      (save-excursion
        (goto-char (icomplete--field-end))
        ;; Insert the match-status information:
        (when (and (or icomplete-show-matches-on-no-input
                       (not (equal (icomplete--field-string)
                                   icomplete--initial-input)))
                   (or
                    ;; Don't bother with delay after certain number of chars:
                    (> (- (point) (icomplete--field-beg))
                       icomplete-max-delay-chars)
                    ;; Don't delay if the completions are known.
                    completion-all-sorted-completions
                    ;; Don't delay if alternatives number is small enough:
                    (and (sequencep (icomplete--completion-table))
                         (< (length (icomplete--completion-table))
                            icomplete-delay-completions-threshold))
                    ;; Delay - give some grace time for next keystroke, before
                    ;; embarking on computing completions:
                    (sit-for icomplete-compute-delay)))
          (when (and
                 icomplete-tidy-shadowed-file-names
                 (eq (icomplete--category) 'file)
                 rfn-eshadow-overlay (overlay-buffer rfn-eshadow-overlay)
                 (eq this-command 'self-insert-command)
                 (= saved-point (icomplete--field-end))
                 (or (>= (- (point) (overlay-end rfn-eshadow-overlay)) 2)
                     (eq ?/ (char-before (- (point) 2)))))
            (delete-region (overlay-start rfn-eshadow-overlay)
                           (overlay-end rfn-eshadow-overlay)))
          (let* ((field-string (icomplete--field-string))
                 (text (while-no-input
                         (icomplete-completions
                          field-string
                          (icomplete--completion-table)
                          (icomplete--completion-predicate)
                          (if (window-minibuffer-p)
                              (eq minibuffer--require-match t)))))
                 (buffer-undo-list t)
                 deactivate-mark)
            ;; Do nothing if while-no-input was aborted.
            (when (stringp text)
              (move-overlay icomplete-overlay (point-min) (point) (current-buffer))
              ;; The current C cursor code doesn't know to use the overlay's
              ;; marker's stickiness to figure out whether to place the cursor
              ;; before or after the string, so let's spoon-feed it the pos.
              (put-text-property 0 1 'cursor t text)
              (overlay-put
               icomplete-overlay 'before-string
               (and icomplete-scroll
                    icomplete-matches-format
                    (let* ((past (length icomplete--scrolled-past))
                           (current (1+ past))
                           (total (+ past (safe-length
                                           completion-all-sorted-completions))))
                      (format icomplete-matches-format current total))))
              (overlay-put icomplete-overlay 'after-string text))))))))