all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Ola x Nilsson <ola.x.nilsson@axis.com>
Cc: Mauro Aranda <maurooaranda@gmail.com>, 64046@debbugs.gnu.org
Subject: bug#64046: 30.0.50; Quoting in customize choice tags
Date: Mon, 28 Aug 2023 15:50:10 +0200	[thread overview]
Message-ID: <87r0nnmg31.fsf@gmx.net> (raw)
In-Reply-To: <jwqa5ubh5f0.fsf@axis.com> (Ola x. Nilsson's message of "Mon, 28 Aug 2023 11:33:09 +0200")

[-- Attachment #1: Type: text/plain, Size: 3084 bytes --]

On Mon, 28 Aug 2023 11:33:09 +0200 Ola x Nilsson <ola.x.nilsson@axis.com> wrote:

> On Fri, Aug 25 2023, Stephen Berman wrote:
>
>> On Fri, 25 Aug 2023 10:02:35 +0200 Ola x Nilsson <ola.x.nilsson@axis.com> wrote:
>>
>>> On Thu, Aug 24 2023, Mauro Aranda wrote:
>>>
>>>> Stephen Berman <stephen.berman@gmx.net> writes:
>>>>
>>>>> On Thu, 24 Aug 2023 17:14:53 -0300 Mauro Aranda
>>>>   <maurooaranda@gmail.com> wrote:
>> [...]
>>>>>> Thinking about it, why do we need to call substitute-command-keys on the
>>>>>> VALUE part (i.e., the cdr of the cons cell), in case of simple item
>>>>>> definitions?
>>>>>>
>>>>>> I re-read the bug report, but I didn't find any reference to why that is
>>>>>> a need.  Did I miss something?
>>>>>
>>>>> Well, the VALUE is displayed on entering a choice.  That is, when I do
>>>>>
>>>>> M-: (widget-choose "Title" '(("Use `a'" . "Use `1'") ("Use `b'"
>>>>   . "Use `2'")))
>>>>>
>>>>> I see curve-quoting in the widget-choose buffer:
>>>>>
>>>>>    Available choices:
>>>>>
>>>>>    0 = Use ‘a’
>>>>>    1 = Use ‘b’
>>>>>
>>>>>    C-g = Quit
>>>>>
>>>>> and when I enter e.g. `0' at the "Title: " prompt in the minibuffer, it
>>>>> displays "Use ‘1’", i.e., with curve-quoting.  But if I omit the call to
>>>>> substitute-command-keys on the cdr in widget-choose, then typing `0' at
>>>>> the "Title: " prompt displays "Use `1'", i.e. with grave-quoting.  But I
>>>>> don't know which one is the intended result.
>>>>
>>>> I see, thank you.  Your last patch looks good to me, then.
>>>
>>> The cdr is the return value, I would expect widget-choose to not
>>> modify that. 
>>
>> I think this is indeed the correct expectation and I should have
>> recognized it instead of looking only at appearances.  But do you agree
>> that applying (at least) quote substitution to the car of the simple
>> item definition is appropriate here?  If so, there is still the question
>> of whether to use substitute-command-keys or just substitute-quotes.
>> I'm inclined to stick with the former but would be fine with going with
>> the latter.
>
> I agree that quote substition should be done on the car of simple item
> definitions.  I have no opinion on susbstitute-command-keys vs
> substitute-quotes.  But I came to think about the TITLE argument,
> shouldn't quote substition be performed on it as well?

I think you're right about that as well, since the title is simply a
display feature.  AFAIK it wouldn't make a noticeable difference for
existing uses of widget-choose in the Customize UI (in the Value menu
the title is simply "Choice" and in the State menu it's "Operation on
<option name>"), but it might be relevant for third party uses or future
uses in Emacs, as well as for ad-hoc uses of simple item definitions.
So applying substition to all uses of TITLE seems appropriate.  The
below patch does this, and also corrects my previous patch by excluding
substition from the cdr of simple item definitions.

Thanks for your feedback.

Steve Berman


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: widget-choose patch --]
[-- Type: text/x-patch, Size: 1692 bytes --]

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index a70598bb6c9..b712be1986b 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -282,16 +282,20 @@ widget-choose
 If ITEMS has simple item definitions, then this function returns the VALUE of
 the chosen element.  If ITEMS is a keymap, then the return value is the symbol
 in the key vector, as in the argument of `define-key'."
-  ;; Apply quote substitution to customize choice menu item text,
+  ;; Apply quote substitution to choice menu title and 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))))))))
-		     items)))
+                       (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)))
+                           (setcar x (substitute-command-keys (car x))))))
+		     items))
+        (title (substitute-command-keys title)))
     (cond ((and (< (length items) widget-menu-max-size)
 	        event (display-popup-menus-p))
 	   ;; Mouse click.

  reply	other threads:[~2023-08-28 13:50 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13 14:02 bug#64046: 30.0.50; Quoting in customize choice tags Stephen Berman
2023-06-13 15:56 ` Eli Zaretskii
2023-06-14 19:51   ` Mauro Aranda
2023-06-14 20:05   ` Mauro Aranda
2023-06-15 11:39     ` Stephen Berman
2023-06-22 20:07       ` Stephen Berman
2023-06-22 22:59         ` Mauro Aranda
2023-06-23 22:18           ` Stephen Berman
2023-06-24  6:37             ` Eli Zaretskii
2023-06-24  8:50               ` Stephen Berman
2023-07-15 13:20 ` Mauro Aranda
2023-07-20 15:48   ` Stephen Berman
2023-07-20 19:11     ` Mauro Aranda
2023-07-20 19:53       ` Stephen Berman
2023-08-21 12:04         ` Ola x Nilsson
2023-08-21 14:51           ` Mauro Aranda
2023-08-24 12:51             ` Stephen Berman
2023-08-24 13:19               ` Stephen Berman
2023-08-24 20:14                 ` Mauro Aranda
2023-08-24 20:54                   ` Stephen Berman
2023-08-24 21:58                     ` Mauro Aranda
2023-08-25  8:02                       ` Ola x Nilsson
2023-08-25 21:50                         ` Stephen Berman
2023-08-28  9:33                           ` Ola x Nilsson
2023-08-28 13:50                             ` Stephen Berman [this message]
2023-08-30 15:29                               ` Mauro Aranda
2023-08-30 16:29                                 ` Stephen Berman
2023-08-30 22:33                                   ` Mauro Aranda
2023-08-30 22:51                                     ` Stephen Berman
2023-08-30 22:58                                       ` Mauro Aranda
2023-08-31  5:41                                         ` Eli Zaretskii
2023-08-31  6:43                                           ` Stefan Kangas
2023-08-31 15:43                                             ` Drew Adams
2023-08-31 20:52                                               ` Stefan Kangas
2023-08-31 22:10                                                 ` Drew Adams
2023-08-31 22:59                                                   ` Stefan Kangas
2023-09-01  1:08                                                     ` Drew Adams
2023-09-01  6:34                                                       ` Eli Zaretskii
2023-09-01 16:17                                                         ` Drew Adams
2023-09-01 23:29                                                           ` Stephen Berman
2023-09-01 23:38                                                             ` Stefan Kangas
2023-09-02  9:49                                                               ` Stephen Berman
2023-09-02 18:59                                                                 ` Stefan Kangas
2023-09-02 21:25                                                                   ` Stephen Berman
2023-09-02  2:12                                                             ` Drew Adams
2023-09-01  6:16                                                     ` Eli Zaretskii
2023-09-01 16:32                                                       ` Drew Adams
2023-08-24 20:53                 ` Stefan Kangas
2023-08-24 21:10                   ` Stephen Berman
2023-08-24 21:14                     ` Stefan Kangas
2023-08-24 21:41                       ` Stephen Berman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0nnmg31.fsf@gmx.net \
    --to=stephen.berman@gmx.net \
    --cc=64046@debbugs.gnu.org \
    --cc=maurooaranda@gmail.com \
    --cc=ola.x.nilsson@axis.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.