Closed cosmicexplorer closed 3 years ago
Thank you for your submission. Can you give me some time to understand the background? It appears that "Rakefile" and "Gemfile" could be moved from smart-compile-alist to smart-compile-build-system-alist. Thanks! Seiji
Thank you for your submission. Can you give me some time to understand the background?
Sure! No worries.
It appears that "Rakefile" and "Gemfile" could be moved from smart-compile-alist to smart-compile-build-system-alist. Thanks! Seiji
Absolutely! And in fact that exposes maybe a new concern: do we want to be able to allow multiple fallbacks?
Because we happen to have build systems build off of other build systems:
cargo build
, or cargo check
for rust code),./pants compile
)So I'll first:
(1) Move Rakefile
and Gemfile
to smart-compile-build-system-alist
!
In my own personal defcustom
I haven't done that super successfully. I did add support for coffescript, but then started using Cakefile
s (like Rakefile
s) recently. Emacs coffee-mode
has a way to configure running coffeescript to get compiled javascipt, I think, and I think the REPL is nice.
However, even with those packages, smart-compile
was able to do these one-shot runs of packages really nicely.
I will create another issue or PR to discuss how to handle fallbacks (like, choosing between build sytems at greater depth in the filesytem hierarchy?
And like I think it could even make sense to perhaps consider merging smart-compile-alist
and smart-compile-build-system-alist
maybe? But i didn't want to break existing users by changing the alist format I think? So wanted to consider this perhaps experimental change to try to make it smaller.
Although, looking at this again because I think Gemfile and Rakefile might be in the same directory? Would we want to go through all matching alist elements?
("Gemfile\'" . "bundle install") ("Rakefile\'" . "rake")
E.g.:
./Gemfile was located. Want to do
bundle install
? (y/n) n ./Rakefile was detected. Want to dorake
(y/n) n ruby myfile.rb
And C-u 4
can reset it as usual, so that could help to automate like all the different setup steps needed for those systems.
- e.g. https://github.com/pantsbuild/pants/blob/master/src/rust/engine/Cargo.toml (where we run
cargo build
, orcargo check
for rust code),- but then in a parent directory also have a https://github.com/pantsbuild/pants/blob/master/pants (where we run
./pants compile
)- which would be very different command-line histories, I think? i pants tries to be extensible so we allow wrapper scripts
To avoid a multiple fallback in a very deep directory tree, I would like to introduce a new variable smart-compile-directory-depth or something like that. Its default value would be 0 or 1. A power user can increase it to 10 or more, but he/she can deal with the deep-directory situation at his/her own risk.
./Gemfile was located. Want to do
bundle install
? (y/n) n ./Rakefile was detected. Want to dorake
(y/n) n ruby myfile.rb
I prefer to go through all matching alist elements. The user will see such many options only at the first time. From the second time, smart-comile runs ruby myfile.rb
. Also, the user can increase/reduce the options by editing smart-compile-build-system-alist
.
Hello! I have been using your package for years! It's great!
Upon realizing it was on MELPA (I had just copied the file into my own emacs init before), I tried to see what I had added to it. I think I have found a really cool way to extend the package, but not by too much.
Problem
This tries to solve two problems:
smart-compile
withmake
, but if myMakefile
isn't right next to the file (e.g.../Makefile
, in a parent directory), it fails.smart-compile
with more than justmake
.These two would happen, for example, in a "monorepo", where I have used it for years at Twitter to smartly compile with pants
Solution
Makefile
in any parent directory,smart-compile
will ask, for example:smart-compile-build-system-alist
, which tries to match the behavior ofsmart-compile-alist
, but instead to run on a "build system file":(REGEX . STRING)
or(REGEX . SEXP)
.REGEX
in any parent directory,Result
smart-compile
willcd
into the directory with the generalized "build system file".smart-compile-build-system-alist
is a(REGEX . STRING)
, it performs the same format string substitution as specified insmart-compile-replace-alist
, where the file is set to the "build file".make
, it also has added support forcargo
and./pants
.Note: we may want to add another
defcustom
to limit how many parents it will check? I just ended up using4
for all of my choices in the code I just deleted: https://github.com/cosmicexplorer/.emacs.d/commit/36079382ede69719058ee048ef57ee8623c3fc38#diff-d7cee76abae5125a7d2d1a746d9e194c93f4ddf48685eac5774ff84a8ff181a5L277-L285.If the above link in the diff doesn't work, try this direct link to where I set this: https://github.com/cosmicexplorer/.emacs.d/blob/bde24aaa9e8fa0dec2f2628712d3966b9610ee0d/lisp/smart-compile.el#L277-L285
I believe I have only used concepts which exist in emacs 22 to implement this. Please let me know if I have missed anything.
Thank you for your work!