colwidth _columns)
(let ((column 0)
(first t)
- (last-title nil)
- (last-string nil))
+ (last-title nil))
(dolist (str 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") (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))))))))
+ (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") (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)))))))
(defun completion--insert-vertical (strings group-fun
_length _wwidth
(let ((group nil)
(column 0)
(row 0)
- (rows)
- (last-string nil))
+ (rows))
(if group-fun
(let* ((str (car strings))
(title (funcall group-fun (if (consp str) (car str) str) nil)))
(goto-char (point-max))
(insert (format completions-group-format title) "\n"))))
(dolist (str group)
- (unless (equal last-string str) ; Remove (consecutive) duplicates.
- (setq last-string str)
- (when (> row rows)
- (forward-line (- -1 rows))
- (setq row 0 column (+ column colwidth)))
- (when (> column 0)
- (end-of-line)
- (while (> (current-column) column)
- (if (eobp)
- (insert "\n")
- (forward-line 1)
- (end-of-line)))
- (insert " \t")
- (set-text-properties (1- (point)) (point)
- `(display (space :align-to ,column))))
- (completion--insert str group-fun)
- (if (> column 0)
- (forward-line)
- (insert "\n"))
- (setq row (1+ row)))))))
+ (when (> row rows)
+ (forward-line (- -1 rows))
+ (setq row 0 column (+ column colwidth)))
+ (when (> column 0)
+ (end-of-line)
+ (while (> (current-column) column)
+ (if (eobp)
+ (insert "\n")
+ (forward-line 1)
+ (end-of-line)))
+ (insert " \t")
+ (set-text-properties (1- (point)) (point)
+ `(display (space :align-to ,column))))
+ (completion--insert str group-fun)
+ (if (> column 0)
+ (forward-line)
+ (insert "\n"))
+ (setq row (1+ row))))))
(defun completion--insert-one-column (strings group-fun &rest _)
- (let ((last-title nil) (last-string nil))
+ (let ((last-title nil))
(dolist (str 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 (format completions-group-format title) "\n")))))
- (completion--insert str group-fun)
- (insert "\n")))
+ (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 (format completions-group-format title) "\n")))))
+ (completion--insert str group-fun)
+ (insert "\n"))
(delete-char -1)))
(defun completion--insert (str group-fun)