[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#67171: 30.0.50; (At least) some VC commands fail with project-prefix
From: |
Dmitry Gutov |
Subject: |
bug#67171: 30.0.50; (At least) some VC commands fail with project-prefix-or-any-command |
Date: |
Fri, 8 Dec 2023 22:37:29 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
On 07/12/2023 13:23, Sean Whitton wrote:
Hello,
On Thu 07 Dec 2023 at 02:10am +02, Dmitry Gutov wrote:
On 06/12/2023 17:09, Sean Whitton wrote:
Combined with
(put 'vc-print-root-log 'project-switch-with-default-directory t)
somewhere in your init script.
The alternative would be tagging all project-related commands. Even if we also
check for the 'project-' prefix in command's name, the user-defined commands
using the project API will be affected (I don't know for how many it would be
a problem, but still).
This solution makes sense. We definitely want the user to have a way to
tag additional commands. But couldn't we pre-tag some, like this one,
for example? It is difficult to think of wanting to not have this one
tagged. And the user could always remove the tag in their init.
That would be a half-measure still. And why this command but not others? And
if others too, then which ones?
It might seem natural to you, but it never occurred to add vc-print-root-log
to project-prefix-map to me. What other commands would not occur to us both
but would to others?
Would it make sense to tag all VC commands? Or just consider the 'vc-' prefix
as a negative?
To consider the "alternative" approach once more, we could recognize the
'project-' commands as the ones that should use
project-current-directory-override. But the rest would use default-directory,
unless they have a property 'project-related' or something. That would exclude
user-defined commands in the beginning, but then again, the difference between
binding project-current-directory-override and default-directory might matter
only to a small fraction of them.
I think the half-measure is okay, for it can become a fuller measure
over time. Let's not do anything blanket for all vc- or project-
commands, but just provide the facility, and pre-tag commands as we
realise it couldn't make sense not to want the facility for those.
Sorry, but I still don't see how vc-print-root-log is different from
many others (vc-print-* family of commands, or rgrep, or... commands
like run-python (ensuring that it runs in a specific dir might mean the
correct venv and python version), or find-dired, or etc.
So if we tag vc-print-root-log in-tree, it seems like we'd need to add
properties for all of the above, and more (also in-tree).
I have now pushed the patch with the opposite solution to master.
Its saving grace is that, like Juri also noted, most project-related
commands wouldn't require this property to be set to function
adequately. The ones that need the original value of default-directory
in the current buffer should be in strict minority.
Please check that it works for you, and for any further problems.
This is now in master:
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index a81bb63fba4..7789243cb00 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1841,10 +1841,12 @@ project-execute-extended-command
;;;###autoload
(defun project-any-command (&optional overriding-map prompt-format)
"Run the next command in the current project.
-If the command is in `project-prefix-map', it gets passed that
-info with `project-current-directory-override'. Otherwise,
-`default-directory' is temporarily set to the current project's
-root.
+
+If the command name starts with `project-', or its symbol has
+property `project-related', it gets passed the project to use
+with the variable `project-current-directory-override'.
+Otherwise, `default-directory' is temporarily set to the current
+project's root.
If OVERRIDING-MAP is non-nil, it will be used as
`overriding-local-map' to provide shorter bindings from that map
@@ -1856,15 +1858,11 @@ project-any-command
(key-binding (read-key-sequence
(format prompt-format (project-root
pr)))
t)))
- (root (project-root pr))
- found)
+ (root (project-root pr)))
(when command
- ;; We could also check the command name against "\\`project-",
- ;; and/or (get command 'project-command).
- (map-keymap
- (lambda (_evt cmd) (if (eq cmd command) (setq found t)))
- project-prefix-map)
- (if found
+ (if (when (symbolp command)
+ (or (string-prefix-p "project-" (symbol-name command))
+ (get command 'project-command)))
(let ((project-current-directory-override root))
(call-interactively command))
(let ((default-directory root))
bug#67171: 30.0.50; (At least) some VC commands fail with project-prefix-or-any-command, Juri Linkov, 2023/12/06