]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve 'read-multiple-choice--long-answers' annotations
authorEshel Yaron <me@eshelyaron.com>
Wed, 27 Mar 2024 20:46:04 +0000 (21:46 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 27 Mar 2024 20:46:04 +0000 (21:46 +0100)
lisp/emacs-lisp/rmc.el
lisp/simple.el

index 41f168f70d8608f83595f586c8368793a736d8fc..daf40c63050eb1f97310beec0638b44cc6deb628 100644 (file)
@@ -323,10 +323,20 @@ Usage example:
              (completion-table-with-metadata
               cands
               `((category . multiple-choice)
-                (annotation-function
-                 . ,(lambda (cand)
-                      (when-let ((desc (caddr (assq (aref cand 0) choices))))
-                        (concat " " desc))))))
+                (affixation-function
+                 . ,(lambda (cands)
+                      (let ((max (1+ (seq-max (mapcar #'string-width cands)))))
+                        (mapcar
+                         (lambda (cand)
+                           (list cand ""
+                                 (when-let ((desc (caddr (assq (aref cand 0)
+                                                               choices))))
+                                   (concat
+                                    (make-string (- max (string-width cand))
+                                                 ?\s)
+                                    (propertize desc 'face
+                                                'completions-annotations)))))
+                         cands))))))
              nil t nil nil cands))))
     (unless (string-empty-p answer) (assq (aref answer 0) choices))))
 
index 60e881bbf888535f7805e00ad8d4d6e8a8f0c4a7..ce7ce88669b0b6feec9fcd326f3228a3718fa8e6 100644 (file)
@@ -11191,7 +11191,7 @@ killed."
                    (buffer-name))
            '((?n "no" "exit without doing anything")
              (?y "yes" "kill buffer without saving")
-             (?s "save and then kill" "save the buffer and then kill it"))
+             (?s "save and kill" "save the buffer and then kill it"))
            nil nil (and (not use-short-answers)
                         (not (use-dialog-box-p)))))))
     (unless (= response ?n)