bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#64046: 30.0.50; Quoting in customize choice tags


From: Stephen Berman
Subject: bug#64046: 30.0.50; Quoting in customize choice tags
Date: Thu, 24 Aug 2023 15:19:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

On Thu, 24 Aug 2023 14:51:39 +0200 Stephen Berman <stephen.berman@gmx.net> 
wrote:

> On Mon, 21 Aug 2023 11:51:36 -0300 Mauro Aranda <maurooaranda@gmail.com> 
> wrote:
>
>> Ola x Nilsson <ola.x.nilsson@axis.com> writes:
> [...]
>>> I think I ran into another problem with the change.
>>> Using the simple item definitions (described in the docstring), this
>>> call
>>>
>>> (widget-choose "Title" '(("Option1" . "Foo") ("Option 2" . "Bar")))
>>>
>>> will fail with
>>>
>>> (wrong-type-argument (listp "Foo"))
>>
>> Thanks for reporting this.
>>
>>> Or did I misunderstand how that mode works?
>>
>> I think your recipe should work, and it worked before.
>>
>> Hopefully Stephen can take a look at it.
>
> Thanks for reporting this regression.  The following patch, which tests
> for proper-list-p instead of consp, fixes the above case and still
> applies substitute-command-keys correctly in the other cases brought up
> in this bug:
>
> diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
> index a70598bb6c9..6b4446a0be8 100644
> --- a/lisp/wid-edit.el
> +++ b/lisp/wid-edit.el
> @@ -285,7 +285,7 @@ widget-choose
>    ;; Apply quote substitution to customize choice menu item text,
>    ;; whether it occurs in a widget buffer or in a popup menu.
>    (let ((items (mapc (lambda (x)
> -                       (when (consp x)
> +                       (when (proper-list-p x)
>                           (dotimes (i (1- (length x)))
>                             (when (stringp (nth i x))
>                               (setcar (nthcdr i x)
>
>
> However, if the car and cdr of the simple items are strings containing
> grave-style quoting, e.g. as in the following:
>
> (widget-choose "Title" '(("Use `a'" . "Use `a'") ("Use `b'" . "Use `b'")))
>
> and this quoting is supposed to appear on evaluation as curve-style,
> then something like the following patch seems to be required:
>
> diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
> index a70598bb6c9..40d7b5b902c 100644
> --- a/lisp/wid-edit.el
> +++ b/lisp/wid-edit.el
> @@ -285,12 +285,17 @@ widget-choose
>    ;; Apply quote substitution to customize choice menu item text,
>    ;; whether it occurs in a widget buffer or in a popup menu.
>    (let ((items (mapc (lambda (x)
> -                       (when (consp x)
> -                         (dotimes (i (1- (length x)))
> -                           (when (stringp (nth i x))
> -                             (setcar (nthcdr i x)
> -                                     (substitute-command-keys
> -                                      (car (nthcdr i x))))))))
> +                       (if (proper-list-p x)
> +                           (dotimes (i (1- (length x)))
> +                             (when (stringp (nth i x))
> +                               (setcar (nthcdr i x)
> +                                       (substitute-command-keys
> +                                        (car (nthcdr i x))))))
> +                         ;; ITEMS has simple item definitions.
> +                         (when (and (consp x) (stringp (car x))
> +                                    (stringp (cdr x)))
> +                           (setcar x (substitute-command-keys (car x)))
> +                           (setcdr x (substitute-command-keys (cdr x))))))
>                    items)))
>      (cond ((and (< (length items) widget-menu-max-size)
>               event (display-popup-menus-p))
>
>
> I don't see any obvious problem with this, but I'm not sure.

Right after sending, I found an obvious problem: only one of the car or
the cdr might be a string.  The following patch accounts for this:

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index a70598bb6c9..891e98b6de5 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -285,12 +285,18 @@ widget-choose
   ;; Apply quote substitution to customize choice menu item text,
   ;; whether it occurs in a widget buffer or in a popup menu.
   (let ((items (mapc (lambda (x)
-                       (when (consp x)
-                         (dotimes (i (1- (length x)))
-                           (when (stringp (nth i x))
-                             (setcar (nthcdr i x)
-                                     (substitute-command-keys
-                                      (car (nthcdr i x))))))))
+                       (if (proper-list-p x)
+                           (dotimes (i (1- (length x)))
+                             (when (stringp (nth i x))
+                               (setcar (nthcdr i x)
+                                       (substitute-command-keys
+                                        (car (nthcdr i x))))))
+                         ;; ITEMS has simple item definitions.
+                         (when (consp x)
+                           (when (stringp (car x))
+                             (setcar x (substitute-command-keys (car x))))
+                           (when (stringp (cdr x))
+                             (setcdr x (substitute-command-keys (cdr x)))))))
                     items)))
     (cond ((and (< (length items) widget-menu-max-size)
                event (display-popup-menus-p))
Steve Berman

reply via email to

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