GNU bug report logs - #75933
29; Disabling smerge-command-prefix results in error

Previous Next

Package: emacs;

Reported by: Jonas Bernoulli <jonas <at> bernoul.li>

Date: Wed, 29 Jan 2025 19:29:01 UTC

Severity: normal

To reply to this bug, email your comments to 75933 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#75933; Package emacs. (Wed, 29 Jan 2025 19:29:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jonas Bernoulli <jonas <at> bernoul.li>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 29 Jan 2025 19:29:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jonas Bernoulli <jonas <at> bernoul.li>
To: bug-gnu-emacs <at> gnu.org
Subject: 29; Disabling smerge-command-prefix results in error
Date: Wed, 29 Jan 2025 20:28:32 +0100
Hello,

In Emacs 28 the prefix key was defined like this:

  (defcustom smerge-command-prefix "\C-c^"
    "Prefix for `smerge-mode' commands."
    :type '(choice (const :tag "ESC"   "\e")
                   (const :tag "C-c ^" "\C-c^" )
                   (const :tag "none"  "")
                   string))

  (easy-mmode-defmap smerge-mode-map
    `((,smerge-command-prefix . ,smerge-basic-map))
    "Keymap for `smerge-mode'.")

In Emacs 29.1 (after 2ae3b66fa80 and some fixup commits), the former
remained as it was in 28, but the latter was replaced with:

  (defvar-keymap smerge-mode-map
    (key-description smerge-command-prefix) smerge-basic-map)

Setting the option to "", to add no prefix command, results in:

  keymap--check: "" is not a valid key definition; see `key-valid-p'

A possible fix could be to do it old-school:

  (defvar smerge-mode-map
    (let ((map (make-sparse-keymap))
          (key (key-description smerge-command-prefix)))
      (when (key-valid-p key)
        (keymap-set map key smerge-basic-map))
      map))

Best regards,
Jonas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75933; Package emacs. (Wed, 29 Jan 2025 19:55:02 GMT) Full text and rfc822 format available.

Message #8 received at 75933 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jonas Bernoulli <jonas <at> bernoul.li>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 75933 <at> debbugs.gnu.org
Subject: Re: bug#75933: 29; Disabling smerge-command-prefix results in error
Date: Wed, 29 Jan 2025 21:53:29 +0200
> Date: Wed, 29 Jan 2025 20:28:32 +0100
> From:  Jonas Bernoulli via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> Hello,
> 
> In Emacs 28 the prefix key was defined like this:
> 
>   (defcustom smerge-command-prefix "\C-c^"
>     "Prefix for `smerge-mode' commands."
>     :type '(choice (const :tag "ESC"   "\e")
>                    (const :tag "C-c ^" "\C-c^" )
>                    (const :tag "none"  "")
>                    string))
> 
>   (easy-mmode-defmap smerge-mode-map
>     `((,smerge-command-prefix . ,smerge-basic-map))
>     "Keymap for `smerge-mode'.")
> 
> In Emacs 29.1 (after 2ae3b66fa80 and some fixup commits), the former
> remained as it was in 28, but the latter was replaced with:
> 
>   (defvar-keymap smerge-mode-map
>     (key-description smerge-command-prefix) smerge-basic-map)
> 
> Setting the option to "", to add no prefix command, results in:
> 
>   keymap--check: "" is not a valid key definition; see `key-valid-p'
> 
> A possible fix could be to do it old-school:
> 
>   (defvar smerge-mode-map
>     (let ((map (make-sparse-keymap))
>           (key (key-description smerge-command-prefix)))
>       (when (key-valid-p key)
>         (keymap-set map key smerge-basic-map))
>       map))

Thanks.

Stefan, can you suggest a solution?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75933; Package emacs. (Wed, 05 Feb 2025 23:09:02 GMT) Full text and rfc822 format available.

Message #11 received at 75933 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Jonas Bernoulli <jonas <at> bernoul.li>
Cc: 75933 <at> debbugs.gnu.org
Subject: Re: bug#75933: 29; Disabling smerge-command-prefix results in error
Date: Wed, 05 Feb 2025 18:08:26 -0500
>   (easy-mmode-defmap smerge-mode-map
>     `((,smerge-command-prefix . ,smerge-basic-map))
>     "Keymap for `smerge-mode'.")
>
> In Emacs 29.1 (after 2ae3b66fa80 and some fixup commits), the former
> remained as it was in 28, but the latter was replaced with:
>
>   (defvar-keymap smerge-mode-map
>     (key-description smerge-command-prefix) smerge-basic-map)
>
> Setting the option to "", to add no prefix command, results in:
>
>   keymap--check: "" is not a valid key definition; see `key-valid-p'

Emacs Emacs<29 setting the option to "" resulted in keeping
`smerge-mode-map` empty, AFAICT.  Is that what you wanted or did you
expect all the bindings of `smerge-basic-map` to be made available
without a prefix?

To my mind the value "" would be closer to meaning that all the bindings
of `smerge-basic-map` should be made available without a prefix, and if
we want to allow the bindings to be completely absent, it might make
more sense to use a nil value.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75933; Package emacs. (Thu, 06 Feb 2025 13:51:02 GMT) Full text and rfc822 format available.

Message #14 received at 75933 <at> debbugs.gnu.org (full text, mbox):

From: Jonas Bernoulli <jonas <at> bernoul.li>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 75933 <at> debbugs.gnu.org
Subject: Re: bug#75933: 29; Disabling smerge-command-prefix results in error
Date: Thu, 06 Feb 2025 14:50:04 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>>   (easy-mmode-defmap smerge-mode-map
>>     `((,smerge-command-prefix . ,smerge-basic-map))
>>     "Keymap for `smerge-mode'.")
>>
>> In Emacs 29.1 (after 2ae3b66fa80 and some fixup commits), the former
>> remained as it was in 28, but the latter was replaced with:
>>
>>   (defvar-keymap smerge-mode-map
>>     (key-description smerge-command-prefix) smerge-basic-map)
>>
>> Setting the option to "", to add no prefix command, results in:
>>
>>   keymap--check: "" is not a valid key definition; see `key-valid-p'
>
> Emacs Emacs<29 setting the option to "" resulted in keeping
> `smerge-mode-map` empty, AFAICT.  Is that what you wanted or did you
> expect all the bindings of `smerge-basic-map` to be made available
> without a prefix?

Well *I* am perfectly happy with the defaults.  But there's at least one
Magit user who never uses Smerge and thus doesn't want keymaps cluttered
with its bindings.

> To my mind the value "" would be closer to meaning that all the bindings
> of `smerge-basic-map` should be made available without a prefix, and if
> we want to allow the bindings to be completely absent, it might make
> more sense to use a nil value.

That does make sense to me too, but I don't think that users who have
set this to "", to not even use a top-level binding for Smerge commands,
would be happy if the meaning were changed to add *multiple* top-level
bindings, that's worse for them than the default of one prefix keymap.
So it might be better to use two new symbols, such as 'top-level and
'none, and make "" a backward compatibility alias for 'none.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75933; Package emacs. (Sat, 22 Feb 2025 09:17:01 GMT) Full text and rfc822 format available.

Message #17 received at 75933 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jonas Bernoulli <jonas <at> bernoul.li>
Cc: 75933 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#75933: 29; Disabling smerge-command-prefix results in error
Date: Sat, 22 Feb 2025 11:16:14 +0200
Ping! How should we proceed with this issue?

> Cc: 75933 <at> debbugs.gnu.org
> Date: Thu, 06 Feb 2025 14:50:04 +0100
> From:  Jonas Bernoulli via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> 
> >>   (easy-mmode-defmap smerge-mode-map
> >>     `((,smerge-command-prefix . ,smerge-basic-map))
> >>     "Keymap for `smerge-mode'.")
> >>
> >> In Emacs 29.1 (after 2ae3b66fa80 and some fixup commits), the former
> >> remained as it was in 28, but the latter was replaced with:
> >>
> >>   (defvar-keymap smerge-mode-map
> >>     (key-description smerge-command-prefix) smerge-basic-map)
> >>
> >> Setting the option to "", to add no prefix command, results in:
> >>
> >>   keymap--check: "" is not a valid key definition; see `key-valid-p'
> >
> > Emacs Emacs<29 setting the option to "" resulted in keeping
> > `smerge-mode-map` empty, AFAICT.  Is that what you wanted or did you
> > expect all the bindings of `smerge-basic-map` to be made available
> > without a prefix?
> 
> Well *I* am perfectly happy with the defaults.  But there's at least one
> Magit user who never uses Smerge and thus doesn't want keymaps cluttered
> with its bindings.
> 
> > To my mind the value "" would be closer to meaning that all the bindings
> > of `smerge-basic-map` should be made available without a prefix, and if
> > we want to allow the bindings to be completely absent, it might make
> > more sense to use a nil value.
> 
> That does make sense to me too, but I don't think that users who have
> set this to "", to not even use a top-level binding for Smerge commands,
> would be happy if the meaning were changed to add *multiple* top-level
> bindings, that's worse for them than the default of one prefix keymap.
> So it might be better to use two new symbols, such as 'top-level and
> 'none, and make "" a backward compatibility alias for 'none.
> 
> 
> 
> 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75933; Package emacs. (Sat, 22 Feb 2025 16:24:01 GMT) Full text and rfc822 format available.

Message #20 received at 75933 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Jonas Bernoulli <jonas <at> bernoul.li>, 75933 <at> debbugs.gnu.org
Subject: Re: bug#75933: 29; Disabling smerge-command-prefix results in error
Date: Sat, 22 Feb 2025 11:23:41 -0500
> Ping! How should we proceed with this issue?

Maybe another way to look at it is that it's again bumping into
`define-keymap`s limitation that you can't easily "deactivate"
a binding.

We saw that back in the bug#68213: if a keymap is defined where some of
the key sequences are chosen dynamically (typically coming from a config
var), we tend to get into trouble where it can be difficult/inconvenient
to avoid duplicate key bindings (we fixed that problem by demoting that
error to a warning), and similarly there's no easy way for the user to
say "no key at all" (which was another way we could have fixed the
problem in bug#68213).

Maybe we should have an "impossible key sequence" (like we have the
`regexp-unmatchable`) and offer it in the customization interface?
And then arrange for `define-keymap` (and maybe others) to handle
it accordingly.

Not sure what that key sequence should be, but some choices that come to
mind would be:

- nil
- [] (a.k.a "")
- [impossible]


        Stefan

>> Cc: 75933 <at> debbugs.gnu.org
>> Date: Thu, 06 Feb 2025 14:50:04 +0100
>> From:  Jonas Bernoulli via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> 
>> >>   (easy-mmode-defmap smerge-mode-map
>> >>     `((,smerge-command-prefix . ,smerge-basic-map))
>> >>     "Keymap for `smerge-mode'.")
>> >>
>> >> In Emacs 29.1 (after 2ae3b66fa80 and some fixup commits), the former
>> >> remained as it was in 28, but the latter was replaced with:
>> >>
>> >>   (defvar-keymap smerge-mode-map
>> >>     (key-description smerge-command-prefix) smerge-basic-map)
>> >>
>> >> Setting the option to "", to add no prefix command, results in:
>> >>
>> >>   keymap--check: "" is not a valid key definition; see `key-valid-p'
>> >
>> > Emacs Emacs<29 setting the option to "" resulted in keeping
>> > `smerge-mode-map` empty, AFAICT.  Is that what you wanted or did you
>> > expect all the bindings of `smerge-basic-map` to be made available
>> > without a prefix?
>> 
>> Well *I* am perfectly happy with the defaults.  But there's at least one
>> Magit user who never uses Smerge and thus doesn't want keymaps cluttered
>> with its bindings.
>> 
>> > To my mind the value "" would be closer to meaning that all the bindings
>> > of `smerge-basic-map` should be made available without a prefix, and if
>> > we want to allow the bindings to be completely absent, it might make
>> > more sense to use a nil value.
>> 
>> That does make sense to me too, but I don't think that users who have
>> set this to "", to not even use a top-level binding for Smerge commands,
>> would be happy if the meaning were changed to add *multiple* top-level
>> bindings, that's worse for them than the default of one prefix keymap.
>> So it might be better to use two new symbols, such as 'top-level and
>> 'none, and make "" a backward compatibility alias for 'none.
>> 
>> 
>> 
>> 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75933; Package emacs. (Sat, 22 Feb 2025 23:11:02 GMT) Full text and rfc822 format available.

Message #23 received at 75933 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
 text editors" <bug-gnu-emacs <at> gnu.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Jonas Bernoulli <jonas <at> bernoul.li>,
 75933 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#75933: 29; Disabling smerge-command-prefix results in error
Date: Sat, 22 Feb 2025 18:10:36 -0500
Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> writes:

>> Ping! How should we proceed with this issue?
>
> Maybe another way to look at it is that it's again bumping into
> `define-keymap`s limitation that you can't easily "deactivate"
> a binding.
>
> We saw that back in the bug#68213: if a keymap is defined where some of
> the key sequences are chosen dynamically (typically coming from a config
> var), we tend to get into trouble where it can be difficult/inconvenient
> to avoid duplicate key bindings (we fixed that problem by demoting that
> error to a warning), and similarly there's no easy way for the user to
> say "no key at all" (which was another way we could have fixed the
> problem in bug#68213).
>
> Maybe we should have an "impossible key sequence" (like we have the
> `regexp-unmatchable`) and offer it in the customization interface?

The question is ill-formed. Why do we have keymaps with bindings based
on random defcustoms in the first place? The proper place to customize a
keymap is the keymap. 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75933; Package emacs. (Sat, 22 Feb 2025 23:12:01 GMT) Full text and rfc822 format available.

This bug report was last modified 111 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.