Function: completion--insert-horizontal
completion--insert-horizontal is a byte-compiled function defined in
minibuffer.el.gz.
Signature
(completion--insert-horizontal STRINGS GROUP-FUN LENGTH WWIDTH COLWIDTH COLUMNS LINES &optional LAST-TITLE)
Source Code
;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun completion--insert-horizontal (strings group-fun
length wwidth
colwidth columns lines
&optional last-title)
(let ((column 0)
(first t)
(last-string nil)
str)
(while strings
(setq str (pop strings))
(unless (equal last-string str) ; Remove (consecutive) duplicates.
(setq last-string str)
(when group-fun
(let ((title (funcall group-fun (if (consp str) (car str) str) nil)))
(unless (equal title last-title)
(setq last-title title)
(when title
(insert (if first "" "\n")
(format completions-group-format title) "\n")
(setq column 0
first t)))))
(unless first
;; FIXME: `string-width' doesn't pay attention to
;; `display' properties.
(if (< wwidth (+ column
(max colwidth
(if (consp str)
(apply #'+ (mapcar #'string-width str))
(string-width str)))))
;; No space for `str' at point, move to next line.
(progn
(insert "\n")
(when (and lines (> (line-number-at-pos) lines))
(throw 'completions-truncated
(lambda ()
(completion--insert-horizontal
;; Add str back, since we haven't inserted it yet.
(cons str strings) group-fun length wwidth colwidth
columns nil last-title))))
(setq column 0))
(insert " \t")
;; Leave the space unpropertized so that in the case we're
;; already past the goal column, there is still
;; a space displayed.
(set-text-properties (1- (point)) (point)
;; We can set tab-width using
;; completion-tab-width, but
;; the caller can prefer using
;; \t to align prefixes.
`(display (space :align-to ,column)))
nil))
(setq first nil)
(completion--insert str group-fun)
;; Next column to align to.
(setq column (+ column
;; Round up to a whole number of columns.
(* colwidth (ceiling length colwidth))))))))