Subject: Re: bug#64417: 30.0.50; keymap-unset :REMOVE keyword not working

From: German Pacenza <[email-masked]>
Date: Sun, 02 Jul 2023 13:54:38 -0300

Stefan Monnier <[email-masked]> writes:

> Thanks for providing a great example of why the `remove` arg of
> `keymap-unset` is a problematic feature :-)
>
> The technical reason for the above: while `diff-mode-map` has no parent,
> the keymap bound to ESC in `diff-mode-map` has `diff-mode-shared-map`
> as parent, and `M-SPC` is the same (for keymap purposes) as `ESC SPC`.
> Of curse, there's no binding of anything to `scroll-up-command` itself
> in `diff-mode-shared-map` itself: the binding is to be found in
> `diff-mode-shared-map`s parent, `special-mode-map`.
>
> So we can't *remove* the binding from `M-SPC` to `scroll-up-command`
> without modifying some other keymap.
>
> So, the code is doing The Right Thing :-(
>
>
>         Stefan
>

I added that line to my init in October last year and it worked fine. I
git bisect and found the commit that broke it:

commit bb3e0ded9eba71596b34806b302d63977259c3dd
Author: Robert Pluim <[email-masked]>
Date:   Fri Mar 17 09:50:38 2023 +0100

    Don't add a key binding when REMOVE is non-nil
    
    * src/keymap.c (store_in_keymap): Don't add a nil keybinding if we've
    been asked to remove a non-existent binding.  (Bug#62207)

What I do is setting M-SPC in global-map to 'execute-extended-command'
That gets shadowed by diff-mode-map to run 'scroll-up-command', so I use
keymap-unset with :REMOVE to remove it.
Currently keymap-unset removes the binding _without_ :REMOVE and doesn't
do anything _with_ :REMOVE.

-- 
German Pacenza