Subject: bug#41408: Add a project-compile command

From: "Philip K." <[email-masked]>
Date: Tue, 19 May 2020 20:24:48 +0200

Hi,

this patch adds a `compile' command for project.el. It's nothing fancy,
just sets the first directory of `project-roots' as `default-directory',
and then calls the regular compile.

The TODOs mention a `project-build' command, and from my interpretation,
this is a slimmed down version (hence the other name, but also because
it just called compile in a different environment).

-- 
	Philip K.

>From d4aa98e6b01e95f50dc9c6ec02792d4fce542b22 Mon Sep 17 00:00:00 2001
From: Philip K <[email-masked]>
Date: Tue, 19 May 2020 19:30:14 +0200
Subject: [PATCH] Add project-compile command

---
 lisp/progmodes/project.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 44259990bb..15b5899140 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -590,6 +590,18 @@ project-read-file-name-function
                  (function :tag "Custom function" nil))
   :version "27.1")
 
+;;;###autoload
+(defun project-compile ()
+  "Run `compile' in the project root."
+  (interactive)
+  (let* ((pr (project-current t))
+         (roots (project-roots pr))
+         ;; TODO: be more intelligent when choosing a directory. This
+         ;; currently isn't a priority, since no `project-roots'
+         ;; implementation returns more that one directory.
+         (default-directory (car roots)))
+    (call-interactively 'compile)))
+
 (defun project--read-file-cpd-relative (prompt
                                         all-files &optional predicate
                                         hist default)
-- 
2.20.1