GNU bug report logs - #41408
Add a project-compile command

Previous Next

Package: emacs;

Reported by: "Philip K." <philip <at> warpmail.net>

Date: Tue, 19 May 2020 18:26:02 UTC

Severity: normal

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 41408 in the body.
You can then email your comments to 41408 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#41408; Package emacs. (Tue, 19 May 2020 18:26:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Philip K." <philip <at> warpmail.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 19 May 2020 18:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Philip K." <philip <at> warpmail.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Add a project-compile command
Date: Tue, 19 May 2020 20:24:48 +0200
[Message part 1 (text/plain, inline)]
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.

[0001-Add-project-compile-command.patch (text/x-diff, inline)]
From d4aa98e6b01e95f50dc9c6ec02792d4fce542b22 Mon Sep 17 00:00:00 2001
From: Philip K <philip <at> warpmail.net>
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


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41408; Package emacs. (Tue, 19 May 2020 20:00:02 GMT) Full text and rfc822 format available.

Message #8 received at 41408 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: "Philip K." <philip <at> warpmail.net>, 41408 <at> debbugs.gnu.org
Subject: Re: bug#41408: Add a project-compile command
Date: Tue, 19 May 2020 22:59:07 +0300
Hey Philip,

On 19.05.2020 21:24, Philip K. wrote:
> 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).

Is this a command you'd be using yourself? If so, we'll add it happily.

I'm just asking because it's indeed bare-bones, and I basically never 
use 'M-x compile' directly.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41408; Package emacs. (Tue, 19 May 2020 20:08:01 GMT) Full text and rfc822 format available.

Message #11 received at 41408 <at> debbugs.gnu.org (full text, mbox):

From: philip <at> warpmail.net (Philip K.)
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 41408 <at> debbugs.gnu.org
Subject: Re: bug#41408: Add a project-compile command
Date: Tue, 19 May 2020 22:07:08 +0200
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> Hey Philip,
>
> On 19.05.2020 21:24, Philip K. wrote:
>> 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).
>
> Is this a command you'd be using yourself? If so, we'll add it happily.

I wrote it because I needed it, otherwise I wouldn't have suggested it,
hoping others to do. And I assume others do, since projectile has a
similar command (projectile-compile-project).

> I'm just asking because it's indeed bare-bones, and I basically never 
> use 'M-x compile' directly.

Hmm, I regularly use compile/recompile, but maybe that's my mistake. If
you don't mind me asking, how do you invoke compile or related
functions? If I'm doing it the "wrong way", maybe it might not be worth
applying this patch.

-- 
	Philip K.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41408; Package emacs. (Tue, 19 May 2020 21:56:02 GMT) Full text and rfc822 format available.

Message #14 received at 41408 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: "Philip K." <philip <at> warpmail.net>
Cc: 41408 <at> debbugs.gnu.org
Subject: Re: bug#41408: Add a project-compile command
Date: Wed, 20 May 2020 00:55:15 +0300
On 19.05.2020 23:07, Philip K. wrote:

>>> 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).

Regarding the "build" command, I had a bigger idea with a set of 
abstractions and per-project customizations. But so far nobody's needed 
that, it seems.

>> Is this a command you'd be using yourself? If so, we'll add it happily.
> 
> I wrote it because I needed it, otherwise I wouldn't have suggested it,
> hoping others to do.

That's what's important.

> And I assume others do, since projectile has a
> similar command (projectile-compile-project).

Projectile has a great many commands, we'll probably refrain from adding 
them all.

>> I'm just asking because it's indeed bare-bones, and I basically never
>> use 'M-x compile' directly.
> 
> Hmm, I regularly use compile/recompile, but maybe that's my mistake. If
> you don't mind me asking, how do you invoke compile or related
> functions?

Someone could give some pointers, but don't mind me: I usually work with 
Ruby, where the main "compilation" is running the tests. And we do that 
(to take advantage of compilation-mode) via a certain abstraction that 
builds up the list of arguments, and uses a mode derived from 
compilation-mode.

> If I'm doing it the "wrong way", maybe it might not be worth
> applying this patch.

If you find it helpful, then most likely there will be others that do. 
So please don't worry about that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41408; Package emacs. (Tue, 19 May 2020 22:18:02 GMT) Full text and rfc822 format available.

Message #17 received at 41408 <at> debbugs.gnu.org (full text, mbox):

From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
To: philip <at> warpmail.net (Philip K.)
Cc: 41408 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#41408: Add a project-compile command
Date: Wed, 20 May 2020 00:17:33 +0200
philip <at> warpmail.net (Philip K.) writes:

> I wrote it because I needed it, otherwise I wouldn't have suggested it,
> hoping others to do. And I assume others do, since projectile has a
> similar command (projectile-compile-project).

FWIW I have written a similar function in my .emacs, which your command
would replace handily.  Thank you for suggesting this 👍




Reply sent to Dmitry Gutov <dgutov <at> yandex.ru>:
You have taken responsibility. (Tue, 19 May 2020 23:03:02 GMT) Full text and rfc822 format available.

Notification sent to "Philip K." <philip <at> warpmail.net>:
bug acknowledged by developer. (Tue, 19 May 2020 23:03:02 GMT) Full text and rfc822 format available.

Message #22 received at 41408-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: "Philip K." <philip <at> warpmail.net>, 41408-done <at> debbugs.gnu.org
Subject: Re: bug#41408: Add a project-compile command
Date: Wed, 20 May 2020 02:02:04 +0300
On 19.05.2020 21:24, Philip K. wrote:
> this patch adds a `compile' command for project.el

I've applied the patch, but moved the new command to the end.

Thanks!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 17 Jun 2020 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.