[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#63343: 30.0.50; generated mode function will error if mode name cont
From: |
Eli Zaretskii |
Subject: |
bug#63343: 30.0.50; generated mode function will error if mode name contains '%' |
Date: |
Sun, 07 May 2023 08:38:57 +0300 |
> From: No Wayman <iarchivedmywholelife@gmail.com>
> Date: Sat, 06 May 2023 23:46:10 -0400
>
> Mode functions generated via `define-minor-mode' will signal an
> error when messaging a mode's "pretty" name contains "%".
>
> To reproduce:
>
> 1. eval: (define-minor-mode 100%-failure-mode "oops")
> 2. enable or disable the mode.
>
> The line responsible for the error is:
>
> (message ,(format "%s %%sabled%%s" pretty-name)
> (if ,getter "en" "dis") local)))))
>
> The attached patch fixes the issue for me.
>
> >From eb3b41cb4237352aca68e5b14e528cb854c4ab5a Mon Sep 17 00:00:00 2001
> From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
> Date: Sun, 7 May 2023 00:06:18 -0400
> Subject: [PATCH] define-minor-mode: sanitize mode function messages
>
> * emacs-lisp/easy-mmode.el (define-minor-mode): Ensure mode's pretty
> name is not interprted as a message formatting string. e.g. if the
> mode name contains a '%'.
> ---
> lisp/emacs-lisp/easy-mmode.el | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
> index 84e131147cd..3c6a215c9dc 100644
> --- a/lisp/emacs-lisp/easy-mmode.el
> +++ b/lisp/emacs-lisp/easy-mmode.el
> @@ -391,7 +391,7 @@ define-minor-mode
> (not (equal ,last-message
> (current-message))))
> (let ((local ,(if globalp "" " in current buffer")))
> - (message ,(format "%s %%sabled%%s" pretty-name)
> + (message "%s %sabled%s" ,pretty-name
> (if ,getter "en" "dis") local)))))
> ,@(when after-hook `(,after-hook)))
> (force-mode-line-update)
> --
Thanks.
Stefan, any objections to installing this on the release branch?