(completion--insert-vertical): Separate groups completely

Insert the candidates vertically within the groups, but keep the
groups separate using the full width group separators.

* minibuffer.el (completion--insert-vertical): Adjust grouping.
This commit is contained in:
Daniel Mendler 2021-05-02 16:19:42 +02:00 committed by Juri Linkov
parent cacfd0321a
commit 836d69bc60

View file

@ -1869,66 +1869,54 @@ Runs of equal candidate strings are eliminated. GROUP-FUN is a
(defun completion--insert-vertical (strings group-fun (defun completion--insert-vertical (strings group-fun
_length _wwidth _length _wwidth
colwidth columns) colwidth columns)
(let ((column 0) (while strings
(rows (/ (length strings) columns)) (let ((group nil)
(row 0) (column 0)
(last-title nil) (row 0)
(last-string nil) (rows)
(start-point (point)) (last-string nil))
(next 0) (pos 0)) (if group-fun
(dolist (str strings) (let* ((str (car strings))
(unless (equal last-string str) ; Remove (consecutive) duplicates. (title (funcall group-fun (if (consp str) (car str) str) nil)))
(setq last-string str) (while (and strings
(when (> row rows) (equal title (funcall group-fun
(goto-char start-point) (if (consp (car strings))
(setq row 0 column (+ column colwidth))) (car (car strings))
(when group-fun (car strings))
(let ((title (funcall group-fun (if (consp str) (car str) str) nil))) nil)))
(unless (equal title last-title) (push (car strings) group)
(setq last-title title) (pop strings))
(when title (setq group (nreverse group)))
;; Align before title insertion (setq group strings
(when (> column 0) strings nil))
(end-of-line) (setq rows (/ (length group) columns))
(while (> (current-column) column) (when group-fun
(if (eobp) (let* ((str (car group))
(insert "\n") (title (funcall group-fun (if (consp str) (car str) str) nil)))
(forward-line 1) (when title
(end-of-line))) (goto-char (point-max))
(insert " \t") (insert (format completions-group-format title) "\n"))))
(set-text-properties (1- (point)) (point) (dolist (str group)
`(display (space :align-to ,column)))) (unless (equal last-string str) ; Remove (consecutive) duplicates.
(let* ((fmt completions-group-format) (setq last-string str)
(len (length fmt))) (when (> row rows)
;; Adjust display space for columns (forward-line (- -1 rows))
(when (equal (get-text-property (- len 1) 'display fmt) '(space :align-to right)) (setq row 0 column (+ column colwidth)))
(setq fmt (substring fmt)) (when (> column 0)
(put-text-property (- len 1) len (end-of-line)
'display (while (> (current-column) column)
`(space :align-to ,(+ colwidth column -1)) (if (eobp)
fmt)) (insert "\n")
(insert (format fmt title))) (forward-line 1)
;; Align after title insertion (end-of-line)))
(if (> column 0) (insert " \t")
(forward-line) (set-text-properties (1- (point)) (point)
(insert "\n")))))) `(display (space :align-to ,column))))
;; Align before candidate insertion (completion--insert str group-fun)
(when (> column 0) (if (> column 0)
(end-of-line) (forward-line)
(while (> (current-column) column) (insert "\n"))
(if (eobp) (setq row (1+ row)))))))
(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)
;; Align after candidate insertion
(if (> column 0)
(forward-line)
(insert "\n"))
(setq row (1+ row))))))
(defun completion--insert-one-column (strings group-fun &rest _) (defun completion--insert-one-column (strings group-fun &rest _)
(let ((last-title nil) (last-string nil)) (let ((last-title nil) (last-string nil))