Subject: bug#76156: 31.0.50; Wrong STATE when customizing allout-command-prefix

From: "Basil L. Contovounesios" <[email-masked]>
Date: Thu, 13 Feb 2025 22:45:18 +0100

Mauro Aranda [2025-02-09 08:57 -0300] wrote:

> Mauro Aranda <[email-masked]> writes:
>
>> After emacs -Q:
>> (require 'allout)
>> M-x customize-option RET allout-command-prefix
>>
>> The Customize buffer shows up, with STATE being:
>> EDITED, shown value does not take effect until you set or save it.
>>
>> That's wrong, it should say STANDARD.

Agreed, but this must be common to all key-sequence user options, right?

I see the same state with:

- cua-rectangle-mark-key
- flyspell-auto-correct-binding
- footnote-prefix
- gud-key-prefix
- hide-ifdef-mode-prefix-key
- outline-minor-mode-prefix
- viper-toggle-key

So I think this was a regression somewhere in Emacs 27;
the startup state looks as expected in Emacs versions 24 through 26.

> The commit that introduced this is:
>
> commit f7c2fe3337bb5e5721d17f40f79dbc1275e17b0d
> Author: Basil L. Contovounesios <[email-masked]>
> Date:   Wed Feb 28 16:38:21 2024 +0100
>
>     Pacify some docstring control char warnings
>
>     Other instances are discussed in the following thread:
>     https://lists.gnu.org/r/emacs-devel/2024-02/msg00797.html
>
>     * lisp/allout.el (allout-command-prefix): Declare :type as
>     key-sequence.  Mark up key sequences in docstring.
>
> The :type was changed from string to key-sequence, but not the value,

Yes, I was trying to avoid changing the default value.

> and the key-sequence widget requires another format for its value.

What format is that?

- The manual entry for key-sequence links to
  (info "(elisp) Key Sequences") which e.g. includes the text:

    ‘"\C-xl"’ represents the key sequence ‘C-x l’

  according to which I would (and did) interpret "\C-c " as also being a
  key sequence.

- widget-key-sequence-validate takes any string or vector.

- widget-key-sequence-value-to-internal delegates to key-description,
  which works as desired: (key-description "\C-c ") => "C-c SPC".

- widget-key-sequence-value-to-external via key-parse/read-kbd-macro
  drops the trailing space (this surprised me), but this shouldn't give
  rise to the current issue, given it behaved the same in Emacs 26, and
  also given the other affected user options.

> Furthermore, the key-sequence widget has been marked as obsolete since
> 2022.

Yes, at the time I probably thought that in the future someone would
switch the remaining key-sequence user options to some other default
format, but I didn't want to undertake that :).

> Because of compatibility, I recommend keeping the :type as string,
> since other widgets are more restrictive.

No objections from me, although the UI for strings representing keys
leaves something to be desired :).

Thanks,
-- 
Basil