From: Ergus <spacibba@aol.com>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: "Dirk-Jan C. Binnema" <djcb.bulk@gmail.com>, emacs-devel@gnu.org
Subject: Re: [PATCH] Project out of sources compilation
Date: Wed, 3 Apr 2024 21:47:10 +0200 [thread overview]
Message-ID: <ms4tq5o4vuxl5migiybytlp5mbqcqd4iregt2d3uwnqgft47yc@6bsg4udugjlg> (raw)
In-Reply-To: <09a8189d-07e3-4bc5-a4f4-127dcdcec2d1@gutov.dev>
Hi Dmitry:
So far I Think I understood part of your las email about functionality.
On Wed, Apr 03, 2024 at 02:23:03AM +0300, Dmitry Gutov wrote:
>On 01/04/2024 16:52, Ergus wrote:
>>>So having direct support for this in project.el would be quite welcome,
>>>so I can use that instead of my private hacks.
>>>
>>Projectile already have support for many backends and the implementation
>>is pretty clean. I am doing this because I thing that something so basic
>>must be part of vanilla.
>
>Speaking of Projectile, it has this block of definitions of "project
>types". Which could maybe better called "build tool types" in the
>context of this discussion.
>
>It would be nice if we could port them over to a design which would be
>useable by both Projectile and project.el (and together with other
>project.el backends), rather than having every project backend
>re-implement these settings, or re-enumerate the supported types.
>
Their design is actually fine, but I would prefer to keep things simpler
in the api side because project is intended to be more general.
Their use case adds too many functions in order to register, call, test
and generate the different backends I thing it is actually too much for
vanilla. If we want that complexity maybe is better to retake the last
year discussion you mentioned before:
https://lists.gnu.org/archive/html/emacs-devel/2023-05/msg00509.html
But adding that will require also parallel work and code in order to
integrate with project.el.
>That's why the idea of orthogonal APIs seems appealing to me (the
>current one for file listing and root finding; the new one for build
>tools, and compiling, and running, I guess).
>
I would probably insist in a simpler basic feature still in the current
project.el. I can't see the features as a separated thing.
What I would probably propose here is (maybe) to move the vc-backend to
it's own file as a separated package in order to keep the general api
separated from the "plugin". So if a developer wants to create a backend
it is clear whats needed and what the standard implementation example...
>Until we've drawn up some design for the latter, though, maybe a
>customizable function variable will suffice.
>
What I have in mind as now is to add a variable and a method that can be
both optionally defined.
The method defined by backends and the variable by the user (maybe in
dir-locals).
This way the backends won't be forced to define any of these if
compilation is not supported (i.e vs-backend) or if the project is for a
non-compilable languaje (i.e an hypothetic python project)
project-compile-info accepts a second variable that in this case expects
'dir or 'compile-cmd in any case when not implemented the function gives
null and the caller (compile in this case) falls back to the default
values.
This can accept any other command like 'generate-cmd 'test-cmd and so
on. In the future we can define any other random command relying on
these
So far the only we need for compilation is more or less this:
```
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index a10e24f3e28..9d77d5452f3 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -290,8 +290,29 @@ project-external-roots
headers search path, load path, class path, and so on."
nil)
+(cl-defgeneric project-compile-info (_project _info)
+ "Return build information of the current PROJECT.
+
+This function is intended to be defined by the backend when possible.
+Otherwise this returns nil and the `project-compile' command will use
+the default values.
+The current valid values for INFO are `dir' and `compile-cmd'"
+ nil)
+
+(defun project-get-build-dir (project)
+ "Return absolute build directory for the current PROJECT.
+1. Tries the generic function `project-compile-info' with info='dir.
+2. else it return the project-root.
+If the defined path is relative, this expands it relatively to the
+project's root."
+ (let ((dir (or (project-compile-info project 'dir) ;; backend function
+ (project-root project)))) ;; I assume project-root is always absolute
+ (if (file-name-absolute-p dir)
+ dir
+ (expand-file-name dir (project-root project)))))
@@ -1392,10 +1413,15 @@ project-compile
"Run `compile' in the project root."
(declare (interactive-only compile))
(interactive)
- (let ((default-directory (project-root (project-current t)))
- (compilation-buffer-name-function
- (or project-compilation-buffer-name-function
- compilation-buffer-name-function)))
+ ;; I am wondering whenever we need to expand connection local
+ ;; variables at this point... maybe before or inside the let.
+ (let* ((project (project-current t))
+ (default-directory (project-get-build-dir project))
+ (compile-command (or (project-compile-info project 'compile-cmd)
+ compile-command))
+ (compilation-buffer-name-function
+ (or project-compilation-buffer-name-function
+ compilation-buffer-name-function)))
(call-interactively #'compile)))
```
Finally the only missing detail is user side configuration... I was
thinking in a plist defconst (similar to the approach in
eglot-workspace-configuration) so the user can set it completelly or
partially and we only need to do:
(or (plist-get project-info-plist 'compile-cmd)
(project-compile-info project 'compile-cmd)
compile-command)
In this way the user only has one variable to set in the config with all
the parameters optional as well which stays easy, simple in
implementation and with a predictable behavior.
WDYT??
Best,
Ergus
next prev parent reply other threads:[~2024-04-03 19:47 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4wwljrdnra3bsloehioa46y24ozxajajmvf2elvskxxq3mhtg2.ref@pyv2z5snot6h>
2024-03-16 13:12 ` Project out of sources compilation Ergus
2024-03-16 16:50 ` Konstantin Kharlamov
2024-03-16 19:00 ` Ergus
2024-03-16 20:56 ` Konstantin Kharlamov
2024-03-17 2:53 ` Dmitry Gutov
2024-03-17 7:22 ` Ergus
2024-03-17 8:45 ` Eli Zaretskii
2024-03-17 17:33 ` Ergus
2024-03-17 17:38 ` Eli Zaretskii
2024-03-17 17:58 ` Ergus
2024-03-17 11:36 ` Augusto Stoffel
2024-03-17 17:47 ` Ergus
2024-03-19 18:36 ` Ergus
2024-03-27 16:38 ` [PATCH] " Ergus
2024-03-31 2:41 ` Dmitry Gutov
2024-03-31 21:07 ` Ergus
2024-04-01 7:49 ` Dirk-Jan C. Binnema
2024-04-01 13:52 ` Ergus
2024-04-01 15:09 ` Dirk-Jan C. Binnema
2024-04-01 17:18 ` Ergus
2024-04-02 23:23 ` Dmitry Gutov
2024-04-03 19:47 ` Ergus [this message]
2024-04-06 2:05 ` Ergus
2024-04-14 1:44 ` Dmitry Gutov
2024-04-16 14:56 ` Ergus
2024-04-22 17:05 ` Ergus
2024-04-22 18:48 ` Ergus
2024-04-22 21:20 ` Mohsin Kaleem
2024-04-23 15:17 ` Ergus
2024-04-23 19:26 ` Mohsin Kaleem
2024-04-26 0:47 ` Dmitry Gutov
2024-04-02 21:39 ` Richard Stallman
2024-04-02 22:43 ` Dr. Arne Babenhauserheide
2024-04-05 21:40 ` Richard Stallman
2024-04-03 10:40 ` Konstantin Kharlamov
2024-04-03 11:45 ` Eli Zaretskii
2024-04-03 13:31 ` Konstantin Kharlamov
2024-04-03 14:11 ` Eli Zaretskii
2024-04-03 15:00 ` Konstantin Kharlamov
2024-04-03 15:47 ` Eli Zaretskii
2024-04-03 17:27 ` Konstantin Kharlamov
2024-04-03 18:22 ` Eli Zaretskii
2024-04-03 19:08 ` Konstantin Kharlamov
2024-04-03 20:12 ` Ergus
2024-04-04 5:26 ` Eli Zaretskii
2024-04-04 9:59 ` Ergus
2024-04-04 11:59 ` Eli Zaretskii
2024-04-04 12:34 ` Ergus
2024-04-04 13:02 ` Eli Zaretskii
2024-04-04 14:27 ` Ergus
2024-04-04 14:41 ` Eli Zaretskii
2024-04-04 18:15 ` Ergus
2024-04-04 18:56 ` Eli Zaretskii
2024-04-04 20:16 ` Konstantin Kharlamov
2024-04-05 5:11 ` Eli Zaretskii
2024-04-04 5:07 ` Eli Zaretskii
[not found] ` <87jzlefgi9.fsf@dick>
2024-04-03 18:44 ` Konstantin Kharlamov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ms4tq5o4vuxl5migiybytlp5mbqcqd4iregt2d3uwnqgft47yc@6bsg4udugjlg \
--to=spacibba@aol.com \
--cc=djcb.bulk@gmail.com \
--cc=dmitry@gutov.dev \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.