diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el index bedf598d44..63ef8929cd 100644 --- a/lisp/emacs-lisp/rmc.el +++ b/lisp/emacs-lisp/rmc.el @@ -188,9 +188,15 @@ read-multiple-choice (goto-char start) (dolist (line (split-string text "\n")) (end-of-line) - (if (bolp) - (insert line "\n") - (insert line)) + (if (not (bolp)) + (insert line) + (insert (make-string + (max (- (* (mod (1- times) columns) + (+ fill-column 4)) + (current-column)) + 0) + ?\s)) + (insert line "\n")) (forward-line 1))))))))))) (when (buffer-live-p buf) (kill-buffer buf)) diff --git a/test/lisp/emacs-lisp/rmc-tests.el b/test/lisp/emacs-lisp/rmc-tests.el index 9d8f3d4801..ec30026199 100644 --- a/test/lisp/emacs-lisp/rmc-tests.el +++ b/test/lisp/emacs-lisp/rmc-tests.el @@ -38,6 +38,26 @@ test-read-multiple-choice (should (equal (list char str) (read-multiple-choice "Do it? " '((?y "yes") (?n "no")))))))) +(ert-deftest test-read-multiple-choice-help () + (let ((chars '(?? ?a)) + help) + (cl-letf* (((symbol-function #'read-event) + (lambda () + (when (= 1 (length chars)) + (with-current-buffer "*Multiple Choice Help*" + (setq help (buffer-string)))) + (pop chars)))) + (read-multiple-choice + "Choose:" + '((?a "aaa") + (?b "bbb") + (?c "ccc" "a really long description of ccc"))) + (should (equal help "Choose:\n +a: aaa b: bbb c: ccc\n\ + a really long\n\ + description of ccc\n\ + \n\ +"))))) (provide 'rmc-tests) ;;; rmc-tests.el ends here