From b1b10d01a83b2b07a27ce6bcf12cf000fabaf22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 10 Jan 2021 13:18:07 +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): Read command after binding default-directory to project root. --- lisp/progmodes/project.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 62c3cf44cb..1e7f6d7c06 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -974,15 +974,17 @@ project-compile "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))) + (list nil + (consp current-prefix-arg))) + ;; Bind `default-directory' before prompting for COMMAND, so that + ;; command completion works from the project root. + (let ((default-directory (project-root (project-current t))) + (command (or command + (let ((command (eval compile-command))) + (require 'compile) + (if (or compilation-read-command current-prefix-arg) + (compilation-read-command command) + command))))) (compile command comint))) (defun project--read-project-buffer () -- 2.29.2