emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 6bbd1cc5c9 1/2: Format long help texts better in read-multiple-ch


From: Lars Ingebrigtsen
Subject: master 6bbd1cc5c9 1/2: Format long help texts better in read-multiple-choice
Date: Thu, 17 Mar 2022 07:55:48 -0400 (EDT)

branch: master
commit 6bbd1cc5c9cd3db40dcb1ce82f478473b1f78131
Author: Felician Nemeth <felician.nemeth@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Format long help texts better in read-multiple-choice
    
    * lisp/emacs-lisp/rmc.el (rmc--show-help): Format long help texts
    better (bug#54430).
---
 lisp/emacs-lisp/rmc.el            | 12 +++++++++---
 test/lisp/emacs-lisp/rmc-tests.el | 24 +++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el
index e635c7f200..c450505dfd 100644
--- a/lisp/emacs-lisp/rmc.el
+++ b/lisp/emacs-lisp/rmc.el
@@ -112,9 +112,15 @@
                 (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))))))))
     buf))
 
diff --git a/test/lisp/emacs-lisp/rmc-tests.el 
b/test/lisp/emacs-lisp/rmc-tests.el
index c1c46d6400..ed30d82c3b 100644
--- a/test/lisp/emacs-lisp/rmc-tests.el
+++ b/test/lisp/emacs-lisp/rmc-tests.el
@@ -66,5 +66,27 @@
       (should (equal (list char str)
                      (read-multiple-choice "Do it? " '((?y "yes") (?n 
"no"))))))))
 
-(provide 'rmc-tests)
+(ert-deftest test-read-multiple-choice-help ()
+  (let ((chars '(?o ?a))
+        help)
+    (cl-letf* (((symbol-function #'read-event)
+                (lambda ()
+                  (message "chars %S" chars)
+                  (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:
+
+a: [A]aa                 b: [B]bb                 c: [C]cc
+                                                  a really long
+                                                  description of ccc
+                                                  \n?: [?]
+")))))
+
 ;;; rmc-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]