Function: icomplete--augment

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

Signature

(icomplete--augment MD PROSPECTS)

Documentation

Augment completion strings in PROSPECTS with completion metadata MD.

Return a list of strings (COMP PREFIX SUFFIX SECTION). PREFIX and SUFFIX, if non-nil, are obtained from affixation-function or annotation-function metadata. SECTION is obtained from group-function. Consecutive equal sections are avoided. COMP is the element in PROSPECTS or a transformation also given by group-function's second "transformation" protocol.

Source Code

;; Defined in /usr/src/emacs/lisp/icomplete.el.gz
(defun icomplete--augment (md prospects)
  "Augment completion strings in PROSPECTS with completion metadata MD.
Return a list of strings (COMP PREFIX SUFFIX SECTION).  PREFIX
and SUFFIX, if non-nil, are obtained from `affixation-function' or
`annotation-function' metadata.  SECTION is obtained from
`group-function'.  Consecutive `equal' sections are avoided.
COMP is the element in PROSPECTS or a transformation also given
by `group-function''s second \"transformation\" protocol."
  (let* ((aff-fun (or (completion-metadata-get md 'affixation-function)
                      (plist-get completion-extra-properties :affixation-function)))
         (ann-fun (or (completion-metadata-get md 'annotation-function)
                      (plist-get completion-extra-properties :annotation-function)))
         (grp-fun (and completions-group
                       (completion-metadata-get md 'group-function)))
         (annotated
          (cond (aff-fun
           (funcall aff-fun prospects))
          (ann-fun
           (mapcar
            (lambda (comp)
              (let ((suffix (or (funcall ann-fun comp) "")))
                (list comp ""
                      ;; The default completion UI adds the
                      ;; `completions-annotations' face if no
                      ;; other faces are present.
                      (if (text-property-not-all 0 (length suffix) 'face nil suffix)
                          suffix
                        (propertize suffix 'face 'completions-annotations)))))
            prospects))
          (t (mapcar #'list prospects)))))
    (if grp-fun
        (cl-loop with section = nil
                 for (c prefix suffix) in annotated
                 for selectedp = (get-text-property 0 'icomplete-selected c)
                 for tr = (propertize (or (funcall grp-fun c t) c)
                                      'icomplete-selected selectedp)
                 if (not (equal section (setq section (funcall grp-fun c nil))))
                 collect (list tr prefix suffix section)
                 else collect (list tr prefix suffix ))
      annotated)))