GNU bug report logs - #69242
project-any-command with overriding-local-map

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Sun, 18 Feb 2024 18:25:08 UTC

Severity: normal

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 69242 in the body.
You can then email your comments to 69242 AT debbugs.gnu.org in the normal way.

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

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


Report forwarded to dmitry <at> gutov.dev, bug-gnu-emacs <at> gnu.org:
bug#69242; Package emacs. (Sun, 18 Feb 2024 18:25:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to dmitry <at> gutov.dev, bug-gnu-emacs <at> gnu.org. (Sun, 18 Feb 2024 18:25:08 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: project-any-command with overriding-local-map
Date: Sat, 17 Feb 2024 19:17:37 +0200
With 'project-switch-commands' customized to 'project-prefix-or-any-command'
tried to do such a useful thing as applying a diff to a sibling project
with the same source tree:

C-x v =
C-x p p RET
C-c RET a     (diff-apply-buffer)

But it failed with an undefined key.

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'.

Then found this patch fixes the problem completely (no idea why):

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index aa92a73336e..fe866312931 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -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)))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69242; Package emacs. (Mon, 19 Feb 2024 16:03:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Juri Linkov <juri <at> linkov.net>, 69242 <at> debbugs.gnu.org
Subject: Re: bug#69242: project-any-command with overriding-local-map
Date: Mon, 19 Feb 2024 18:01:56 +0200
On 17/02/2024 19:17, Juri Linkov wrote:
> 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):
> 
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index aa92a73336e..fe866312931 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69242; Package emacs. (Tue, 20 Feb 2024 08:00:03 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 69242 <at> debbugs.gnu.org
Subject: Re: bug#69242: project-any-command with overriding-local-map
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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69242; Package emacs. (Thu, 22 Feb 2024 03:43:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Juri Linkov <juri <at> linkov.net>
Cc: 69242 <at> debbugs.gnu.org
Subject: Re: bug#69242: project-any-command with overriding-local-map
Date: Thu, 22 Feb 2024 05:42:15 +0200
On 20/02/2024 09:49, Juri Linkov wrote:
> 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.

Probably not: there is no intention to use any of the local maps there, 
AFAIR.

> 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.

Please do.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69242; Package emacs. (Sun, 25 Feb 2024 07:36:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 69242 <at> debbugs.gnu.org
Subject: Re: bug#69242: project-any-command with overriding-local-map
Date: Sun, 25 Feb 2024 09:33:17 +0200
close 69242 30.0.50
thanks

> LGTM, thanks. Let's see if this one triggers any other edge cases we didn't
> test for.

Ok, now pushed to master.

>> 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.
>
> Please do.

Regarding 'universal-argument', I discovered that currently e.g.
'C-x p p RET C-u C-c C-a' keeps the argument, but loses default-directory
(i.e. sets default-directory back to the old directory).

So tried a patch below, and it keeps default-directory,
but loses the argument.

@@ -1883,7 +1886,11 @@ project-any-command
           (let ((project-current-directory-override root))
             (call-interactively command))
         (let ((default-directory root))
-          (call-interactively command))))))
+          (call-interactively command)))
+      (when (memq command
+                  '( universal-argument universal-argument-more
+                     digit-argument negative-argument))
+        (project-any-command overriding-map prompt-format)))))

Then tried 'C-u C-x p p RET C-c C-a' and it keeps default-directory
and also keeps the C-u argument for 'C-c C-a' after switching the project.

This means no more changes needed because the above key sequence works nicely.
So now closing.




bug marked as fixed in version 30.0.50, send any further explanations to 69242 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Sun, 25 Feb 2024 07:36:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 24 Mar 2024 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 144 days ago.

Previous Next


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