3

There are a number of emacs-lisp checking utilities - for example:

  • checkdoc.
  • package-lint.
  • relint.
  • byte-code-compilation.

Are there existing ways to quickly run this on an entire project without having to access each individually (for every file)?

for example:

emacs-check-code *.el

... would run all the checkers on my elisp files in the current directly, reporting warnings to the console.


Note: I have my own WIP solution, but wanted to avoid reinventing the wheel.

1 Answer 1

3

See the function batch-byte-compile which implements the last of your asks. It is invoked as

emacs --batch -f batch-byte-compile *.el

to compile all the *.el files in the current directory. If you want to byte-compile all the the .el files under the current directory, you can use find and shell facilities:

emacs --batch -f batch-byte-compile $(find . -type f -name '*.el')

If you have thousands of files, this might not work: you might have to split the invocation in order to keep the length of the command line under the maximum allowed, but in most cases it is fine.

The code of batch-byte-compile can serve as an example of how to implement the rest. Basically, it consumes every element of the command line and applies byte-compile-file to each .el file it finds. As long as each of your tools provides such a function, then you can build the same scaffolding around it to consume every element of the command line. Then you can use utilities like find and shell facilities for command line substitution like $(...) to build the command line that will be consumed.

1
  • 1
    See xargs for dealing with many files to pass to the command. Oct 8, 2021 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.