From 7d3ffd7f33276949669414ed4908ad8fee35dd93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 10 Jan 2021 10:43:41 +0100 Subject: [PATCH] Change default-directory before prompting in project-compile This causes command completion to work from the project root, letting users complete top-level folders, make targets, etc. * lisp/progmodes/project.el (project-compile): Simplify using call-interactively, as done with project(-aysnc)-shell-command. --- lisp/progmodes/project.el | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 62c3cf44cb..dade8b4f1c 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -970,20 +970,16 @@ compilation-read-command (declare-function compilation-read-command "compile") ;;;###autoload -(defun project-compile (command &optional comint) +(defun project-compile (command &optional comint interactive) "Run `compile' in the project root. -Arguments the same as in `compile'." - (interactive - (list - (let ((command (eval compile-command))) - (require 'compile) - (if (or compilation-read-command current-prefix-arg) - (compilation-read-command command) - command)) - (consp current-prefix-arg))) - (let* ((pr (project-current t)) - (default-directory (project-root pr))) - (compile command comint))) +COMMAND and COMINT work as with `compile'. When calling this +function from Lisp, you can pretend that it was called +interactively by passing a non-nil INTERACTIVE argument." + (interactive (list nil nil t)) + (let ((default-directory (project-root (project-current t)))) + (if interactive + (call-interactively #'compile) + (compile command comint)))) (defun project--read-project-buffer () (let* ((pr (project-current t)) -- 2.29.2