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