reddit / emacs
Compiling el files in a clean environment
Tohiko · 2022-07-23 18:05
When I compile an `el` file, I sometimes don't see all the possible "undefined" warnings because they depend on the currently loaded packages in my emacs session. For example, if the file depends on the package `org`, some warnings would not show if `org` was loaded when I opened an org file before or if `org` is loaded by default in my init file.
How do I make sure that compilation always happens in a "clean environment" where no packages are loaded? Running with `emacs -Q` would not work since custom packages can never be loaded, for example with `eval-when-compile` (unless I set up the `load-path` which is difficult since it is set by `straight` in my case).
Also, would the compilation result be the same whether these required packages (like `org` in my example) are loaded or not? In other words, is it safe to ignore these warnings?
attento_redaz · 2022-07-23 20:26
Take a look at [Cask](https://github.com/cask/cask) or its more recent alternative, [Eldev](https://github.com/doublep/eldev).
nv-elisp · 2022-07-24 07:12
Have you tried the built-in fly-make mode? It will report most of these types of errors.
akirakom · 2022-07-24 16:49
There are many alternatives. To name a few, [makem.sh](https://github.com/alphapapa/makem.sh/), [eask](https://github.com/emacs-eask/), etc.
attento_redaz · 2022-07-24 17:05
Thanks for the correction and mentioning additional options! I was completely unaware of makem.sh.
github-alphapapa · 2022-07-25 18:27
This is one of the reasons I wrote [makem.sh](https://github.com/alphapapa/makem.sh). I recently added `makem.el` to the repo, which is an Elisp library that provides a Transient menu to make using it very easy (you don't have to use `M-x compile` or a shell).
github-alphapapa · 2022-07-25 18:27
See the recently added `makem.el` file, which makes using it from within Emacs much easier.
github-alphapapa · 2022-07-25 18:29
I hadn't seen Eask before. I was disappointed to see that the first instruction for using it is: "Step 1: Setup NodeJS runtime and
npm"
akirakom · 2022-07-26 03:18
The author (/u/jcs090218) explains the reason for using NodeJS here: [https://www.reddit.com/r/emacs/comments/uqbihf/comment/i8u2agc/?utm\_source=share&utm\_medium=web2x&context=3](https://www.reddit.com/r/emacs/comments/uqbihf/comment/i8u2agc/?utm_source=share&utm_medium=web2x&context=3)
The reason seems to make sense. I personally don't install NodeJS globally, but the author has [packaged](https://github.com/NixOS/nixpkgs/pull/178053) it in Nix.
I think it may be possible to run makem.sh on Windows (via bash on Windows?), but I haven't tried it yet, because I never develop Emacs Lisp packages on Windows.
jcs090218 · 2022-07-26 03:40
Node.js runtime can be wrapped into executable, hence you don't need to install node.js. If you check the release page https://github.com/emacs-eask/eask/releases, there are pre-built binaries (executables) under the "Assets" section.
[deleted] · 2022-07-26 04:22
[deleted]
akirakom · 2022-07-26 05:10
Thanks. I am using NixOS, so I would use your Nix wrapper, but I have my own solution for elisp CI.
jcs090218 · 2022-07-26 06:42
Was just mentioning, but sounds good to me! 👍
I wrote a blog post about comparing Cask and Eask, maybe someone would want to know more about it? Link in https://jcs090218.github.io/blog/emacs-eask/.
As a cross-platform software engineer, I don't see why not to use NodeJS since it takes so much effort to make this layer GOOD. Anyways, Emacs in Windows is often sad, not because of the Emacs itself; it's because of the elisp packages. The formula is like:
✔️ = good cross-platform
❌ = bad cross-platform
```
Emacs (✔️) + CI (❌) = elisp package (❌) # higher chance to be buggy
```
it would be great if:
```
Emacs (✔️) + CI (✔️) = elisp package (✔️) # less chance to be buggy
```
Would be great if we have cross-platform CI solution (Eask, Eldev, etc), but many people seems to use Linux and not caring Windows (again, not the Emacs development, is the Elisp packages). Just saying, it seems like it will always work this way.
Not trying to create hate here, if other alternatives work well. Please use it! They are all awesome tools!❤️
github-alphapapa · 2022-07-26 16:38
Thanks for the link. That's interesting. But I still think that using NodeJS is extreme overkill for the problem he's trying to solve with it. And I don't think that Python is actually such a problem on Windows; there are several ways to use it, including packaging a project into a native executable. But ultimately, the best, most portable, most Emacsy solution would probably be to write it all in Elisp in a session-based way, e.g. as an Eshell extension, so that one wouldn't need to wait for Emacs to start up between each command, only before the first (which shouldn't take too long with `emacs -q -l hypothetically-amazing-pure-elisp-project-tool.el`).
Yes, you should be able to run `makem.sh` on Bash in Windows, if you wanted to.
github-alphapapa · 2022-07-26 16:39
I can't imagine downloading a compiled NodeJS executable to lint and test my Elisp projects, but to each his own. :)
jcs090218 · 2022-07-27 05:12
I wonder why not? Just curious, if you would like to share your thoughts? :)
github-alphapapa · 2022-07-27 12:50
One could write an essay on that topic. For one reason, consider how many extra dependencies are then necessary to be able to lint and test such a project, compared with one that uses standard tools like Bash or Python. Do you want your Emacs projects to be dependent on NodeJS? I don't, nor would I want my Python ones to be. By the same token, I probably wouldn't want my JavaScript projects to be dependent on Emacs or Python.
jcs090218 · 2022-07-27 15:21
Thanks for sharing your thoughts! ❤️
I am a bit confused when you say "to dependent on NodeJS". So you are willing to use Bash/Python, but not NodeJS? I understand people want to use shellscript (Batch/Bash), but aren't Python and NodeJS (JavaSciprt) much similar to each other? 😕 So... I guess it's all about personal preferences? (Just want to clarify)
And, where is the line between **standard** tools and **non-standard** tools? Is NodeJS not the standard tool? I know Bash is (for Linux), but Python? 😕
For my point of view, they operate pretty much the same:
### makem.sh
```
bash -> Bash script -> makem.sh
```
### Cask
```
# Windows
Batch -> Batch script -> Python Interpreter -> Python (file) -> Cask # or Powershell
# Linux/macOS
bash -> Bash script -> Cask
```
### Eask
```
NodeJS runtime -> JavaScript -> Eask
```
And of course, `NodeJS` is much more complex since it's cross-platform. Which part does it make NodeJS non-standard? 😅 Can you elaborate a bit more on this? Thanks!!!
github-alphapapa · 2022-07-28 21:54
> And, where is the line between standard tools and non-standard tools? Is NodeJS not the standard tool? I know Bash is (for Linux), but Python? 😕
I'm not sure if you're being serious, or if you don't know the state of Python in the Linux ecosystem.
> Which part does it make NodeJS non-standard? 😅 Can you elaborate a bit more on this? Thanks!!!
Again, I don't know if you're serious or joking. Anyway, if you want learn about how Bash and Python compare to Node.JS, the Web is at your fingertips. I'm not here to convince you.