Function: completion-hilit-commonality
completion-hilit-commonality is a byte-compiled function defined in
minibuffer.el.gz.
Signature
(completion-hilit-commonality COMPLETIONS PREFIX-LEN &optional BASE-SIZE)
Documentation
Apply font-lock highlighting to a list of completions, COMPLETIONS.
PREFIX-LEN is an integer. BASE-SIZE is an integer or nil (meaning zero).
This adds the face completions-common-part to the first
(PREFIX-LEN - BASE-SIZE) characters of each completion, and the face
completions-first-difference to the first character after that.
It returns a list with font-lock properties applied to each element, and with BASE-SIZE appended as the last element.
Probably introduced at or before Emacs version 24.4.
Source Code
;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun completion-hilit-commonality (completions prefix-len &optional base-size)
"Apply font-lock highlighting to a list of completions, COMPLETIONS.
PREFIX-LEN is an integer. BASE-SIZE is an integer or nil (meaning zero).
This adds the face `completions-common-part' to the first
\(PREFIX-LEN - BASE-SIZE) characters of each completion, and the face
`completions-first-difference' to the first character after that.
It returns a list with font-lock properties applied to each element,
and with BASE-SIZE appended as the last element."
(when completions
(let ((com-str-len (- prefix-len (or base-size 0))))
(nconc
(mapcar
(lambda (elem)
(let ((str
;; Don't modify the string itself, but a copy, since the
;; the string may be read-only or used for other purposes.
;; Furthermore, since `completions' may come from
;; display-completion-list, `elem' may be a list.
(if (consp elem)
(car (setq elem (cons (copy-sequence (car elem))
(cdr elem))))
(setq elem (copy-sequence elem)))))
(font-lock-prepend-text-property
0
;; If completion-boundaries returns incorrect
;; values, all-completions may return strings
;; that don't contain the prefix.
(min com-str-len (length str))
'face 'completions-common-part str)
(if (> (length str) com-str-len)
(font-lock-prepend-text-property com-str-len (1+ com-str-len)
'face
'completions-first-difference
str)))
elem)
completions)
base-size))))