From 17e9cbf7039ad24096b1141deb10cce54f485ee9 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 27 Mar 2024 21:46:04 +0100 Subject: [PATCH] Improve 'read-multiple-choice--long-answers' annotations --- lisp/emacs-lisp/rmc.el | 18 ++++++++++++++---- lisp/simple.el | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el index 41f168f70d8..daf40c63050 100644 --- a/lisp/emacs-lisp/rmc.el +++ b/lisp/emacs-lisp/rmc.el @@ -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)))) diff --git a/lisp/simple.el b/lisp/simple.el index 60e881bbf88..ce7ce88669b 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -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) -- 2.39.5