]> git.eshelyaron.com Git - emacs.git/commitdiff
; Align completion annotations with spaces for multi-column format
authorEshel Yaron <me@eshelyaron.com>
Tue, 16 Jan 2024 09:44:46 +0000 (10:44 +0100)
committerEshel Yaron <me@eshelyaron.com>
Fri, 19 Jan 2024 10:38:07 +0000 (11:38 +0100)
Use actual spaces to align completion annotations instead of
"specified space" display properties, since that allows
'completion--insert-strings' to correctly align multiple completion
columns when 'completions-format' is not 'one-column'.

* lisp/minibuffer.el (completion-styles-affixation)
(completion-file-name-affixation): Align annotations with spaces
instead of using '(space :align-to ...)'  display properties.

lisp/minibuffer.el

index 7c0276290463788819748fe7d2c0d52520dfbc4d..0f503523817f472e48b0428793fec40e04a54086 100644 (file)
@@ -2828,8 +2828,9 @@ current order instead."
              ""
              (if-let ((desc (nth 3 (assoc (intern name)
                                           completion-styles-alist))))
-                 (concat (propertize " " 'display
-                                     `(space :align-to ,(+ max-name 4)))
+                 (concat (make-string (- (+ max-name 4)
+                                         (string-width name))
+                                      ?\s)
                          (propertize
                           ;; Only use the first line.
                           (substring desc 0 (string-search "\n" desc))
@@ -3638,11 +3639,10 @@ same as `substitute-in-file-name'."
                     (concat minibuffer-completion-base file))))
          (list file ""
                (if-let ((ann (file-name-completion-annotation full)))
-                   (propertize
-                    (concat (propertize " " 'display
-                                        `(space :align-to ,(+ max-file 2)))
-                            ann)
-                    'face 'completions-annotations)
+                   (concat (make-string (- (+ max-file 2)
+                                           (string-width file))
+                                        ?\s)
+                           (propertize ann 'face 'completions-annotations))
                  ""))))
      files)))