From 1cf66bfe49c67ae5d46080c8a1d685cb9c04ee62 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Fri, 8 Dec 2023 22:30:48 +0200 Subject: [PATCH] project-any-command: Change the method for passing project root * lisp/progmodes/project.el (project-any-command): Change the check which decides whether 'project-current-directory-override' should be used. Instead of looking in project-prefix-map, see whether the command's name starts with 'project-', or the symbol has the property 'project-command' (bug#67171). --- lisp/progmodes/project.el | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) 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 @@ It's also possible to enter an arbitrary directory not in the list." ;;;###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 @@ which will take priority over the global ones." (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)) -- 2.39.2