Function: completion--insert

completion--insert is a byte-compiled function defined in minibuffer.el.gz.

Signature

(completion--insert STR GROUP-FUN)

Documentation

This function has :after advice: hywiki-completion-exit-function.

Source Code

;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun completion--insert (str group-fun)
  (if (not (consp str))
      (add-text-properties
       (point)
       (let ((str (completion-lazy-hilit str)))
         (insert
          (if group-fun
              (funcall group-fun str 'transform)
            str))
         (point))
       `(mouse-face highlight cursor-face ,completions-highlight-face completion--string ,str))
    ;; If `str' is a list that has 2 elements,
    ;; then the second element is a suffix annotation.
    ;; If `str' has 3 elements, then the second element
    ;; is a prefix, and the third element is a suffix.
    (let* ((prefix (when (nth 2 str) (nth 1 str)))
           (suffix (or (nth 2 str) (nth 1 str))))
      (when prefix
        (let ((beg (point))
              (end (progn (insert prefix) (point))))
          (add-text-properties beg end `(mouse-face nil completion--string ,(car str)))))
      (completion--insert (car str) group-fun)
      (let ((beg (point))
            (end (progn (insert suffix) (point))))
        (add-text-properties beg end `(mouse-face nil completion--string ,(car str)))
        ;; Put the predefined face only when suffix
        ;; is added via annotation-function without prefix,
        ;; and when the caller doesn't use own face.
        (unless (or prefix (text-property-not-all
                            0 (length suffix) 'face nil suffix))
          (font-lock-prepend-text-property
           beg end 'face 'completions-annotations))))))