Subject: bug#69242: project-any-command with overriding-local-map

From: Juri Linkov <[email-masked]>
Date: Tue, 20 Feb 2024 09:49:49 +0200

>> And indeed evaluating in a*vc-diff*  buffer:
>>    M-: (let ((overriding-local-map project-prefix-map)) (key-binding
>> (read-key-sequence "? ") t))
>> returns nil for any longer than 1-key binding such as 'C-c C-a' or 'C-c
>> RET a'.
>
> I suppose that's because you are entering a sequence that belongs to
> a local map (diff-mode-map), and overriding-local-map overrides them
> entirely ("INSTEAD OF" in the docstring), rather than having a higher
> priority, which is overriding-terminal-local-map does.
>
>> Then found this patch fixes the problem completely (no idea why):
>> @@ -1871,7 +1874,7 @@ project-any-command
>>     (interactive)
>>     (let* ((pr (project-current t))
>>            (prompt-format (or prompt-format "[execute in %s]:"))
>> -         (command (let ((overriding-local-map overriding-map))
>> +         (command (let ((overriding-terminal-local-map overriding-map))
>>                       (key-binding (read-key-sequence
>>                                     (format prompt-format (project-root pr)))
>>                                    t)))
>
> LGTM, thanks. Let's see if this one triggers any other edge cases we didn't
> test for.

There is another use of 'overriding-local-map' in project.el:
in 'project--switch-project-command'.  Not sure if this should be
replaced with 'overriding-terminal-local-map' as well.

Also not sure how 'overriding-terminal-local-map' will affect
'universal-argument' that relies on 'overriding-terminal-local-map'.
Maybe project.el should use

  (internal-push-keymap map 'overriding-terminal-local-map)

like in 'set-transient-map'.  Ok, need to try and test this more.