Function: project-any-command

project-any-command is an autoloaded, interactive and byte-compiled function defined in project.el.gz.

Signature

(project-any-command &optional OVERRIDING-MAP PROMPT-FORMAT)

Documentation

Run the next command in the current project.

If the command name starts with project-, or its symbol has property project-aware, 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-terminal-local-map to provide shorter bindings from that map which will take priority over the global ones.

View in manual

Probably introduced at or before Emacs version 30.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/project.el.gz
;;;###autoload
(defun project-any-command (&optional overriding-map prompt-format)
  "Run the next command in the current project.

If the command name starts with `project-', or its symbol has
property `project-aware', 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-terminal-local-map' to provide shorter bindings
from that map which will take priority over the global ones."
  (interactive)
  (let* ((pr (project-current t))
         (prompt-format (or prompt-format "[execute in %s]:"))
         (command (let ((overriding-terminal-local-map overriding-map))
                    (key-binding (read-key-sequence
                                  (format prompt-format (project-root pr)))
                                 t)))
         (root (project-root pr)))
    (when command
      (if (when (symbolp command)
            (or (string-prefix-p "project-" (symbol-name command))
                (get command 'project-aware)))
          (let ((project-current-directory-override root))
            (call-interactively command))
        (let ((default-directory root))
          (call-interactively command))))))