* bug#54430: 27.1; alignment error in read-multiple-choice
@ 2022-03-16 22:21 Felician Nemeth
2022-03-17 11:45 ` Lars Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: Felician Nemeth @ 2022-03-16 22:21 UTC (permalink / raw)
To: 54430
[-- Attachment #1: Type: text/plain, Size: 818 bytes --]
Evaluate the following expression, then ask for help with ?.
(read-multiple-choice "Choose:"
'((?a "aaa")
(?b "bbb")
(?c "ccc" "a really long description of ccc")))
The description of choice "ccc" is misaligned in the help buffer:
------
Choose:
a: aaa b: bbb c: ccc
a really long
description of ccc
------
I expect the help buffer to look something like this:
------
Choose:
a: aaa b: bbb c: ccc
a really long
description of ccc
------
The patch below solves the problem, but I'm sure, it can be improved.
Additionally, I've attempted to write a test for this.
Thanks.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: rmc.patch --]
[-- Type: text/x-diff, Size: 2192 bytes --]
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
[-- Attachment #3: Type: text/plain, Size: 3774 bytes --]
Configured using:
'configure --build x86_64-linux-gnu --prefix=/usr
--sharedstatedir=/var/lib --libexecdir=/usr/lib
--localstatedir=/var/lib --infodir=/usr/share/info
--mandir=/usr/share/man --enable-libsystemd --with-pop=yes
--enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp
--with-sound=alsa --without-gconf --with-mailutils --build
x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
--libexecdir=/usr/lib --localstatedir=/var/lib
--infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
--with-pop=yes
--enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp
--with-sound=alsa --without-gconf --with-mailutils --with-cairo
--with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
'CFLAGS=-g -O2
-ffile-prefix-map=/build/emacs-LlFm6W/emacs-27.1+1=. -fstack-protector-strong
-Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
-D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'
Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD
JSON PDUMPER LCMS2 GMP
Important settings:
value of $LC_ALL: en_US.UTF-8
value of $LC_TIME: hu_HU.UTF-8
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
Major mode: Help
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date subr-x
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils vc-git diff-mode easy-mmode bug-reference help-mode easymenu
cl-loaddefs cl-lib rmc seq byte-opt gv bytecomp byte-compile cconv
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 52259 7417)
(symbols 48 6637 1)
(strings 32 17703 2137)
(string-bytes 1 565498)
(vectors 16 10893)
(vector-slots 8 138879 11136)
(floats 8 23 47)
(intervals 56 497 4)
(buffers 1000 14))
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#54430: 27.1; alignment error in read-multiple-choice
2022-03-16 22:21 bug#54430: 27.1; alignment error in read-multiple-choice Felician Nemeth
@ 2022-03-17 11:45 ` Lars Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-17 11:45 UTC (permalink / raw)
To: Felician Nemeth; +Cc: 54430
Felician Nemeth <felician.nemeth@gmail.com> writes:
> The patch below solves the problem, but I'm sure, it can be improved.
> Additionally, I've attempted to write a test for this.
Thanks; applied to Emacs 29 (with some changes as the formatting has
been altered).
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-17 11:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-16 22:21 bug#54430: 27.1; alignment error in read-multiple-choice Felician Nemeth
2022-03-17 11:45 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.