Function: completion--insert-strings
completion--insert-strings is a byte-compiled function defined in
minibuffer.el.gz.
Signature
(completion--insert-strings STRINGS &optional GROUP-FUN)
Documentation
Insert a list of STRINGS into the current buffer.
The candidate strings are inserted into the buffer depending on the
completions format as specified by the variable completions-format.
Runs of equal candidate strings are eliminated. GROUP-FUN is a
group-function used for grouping the completion candidates.
Source Code
;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun completion--insert-strings (strings &optional group-fun)
"Insert a list of STRINGS into the current buffer.
The candidate strings are inserted into the buffer depending on the
completions format as specified by the variable `completions-format'.
Runs of equal candidate strings are eliminated. GROUP-FUN is a
`group-function' used for grouping the completion candidates."
(when (consp strings)
(let* ((length (apply #'max
(mapcar (lambda (s)
(if (consp s)
(apply #'+ (mapcar #'string-width s))
(string-width s)))
strings)))
(window (get-buffer-window (current-buffer) 0))
(wwidth (if window (1- (window-width window)) 79))
(columns (min
;; At least 2 spaces between columns.
(max 1 (/ wwidth (+ 2 length)))
;; Don't allocate more columns than we can fill.
;; Windows can't show less than 3 lines anyway.
(max 1 (/ (length strings) 2))))
(colwidth (/ wwidth columns))
(lines (or completions-max-height
(frame-height (window-frame window)))))
(unless (or tab-stop-list (null completion-tab-width)
(zerop (mod colwidth completion-tab-width)))
;; Align to tab positions for the case
;; when the caller uses tabs inside prefix.
(setq colwidth (- colwidth (mod colwidth completion-tab-width))))
(let ((completions-continuation
(catch 'completions-truncated
(funcall (intern (format "completion--insert-%s"
completions-format))
strings group-fun length wwidth colwidth columns lines)
nil)))
(when completions-continuation
;; If there's a bug which causes us to not insert the remaining
;; completions automatically, the user can at least press this button.
(setq-local completions--lazy-insert-button
(insert-button
"[Completions truncated, click here to insert the rest.]"
'action #'completion--lazy-insert-strings))
(button-put completions--lazy-insert-button
'completions-continuation completions-continuation))))))