reddit / emacs

flymake-swi-prolog.el - A Flymake backend for SWI-Prolog

eshelyaron · 2022-03-26 17:40
​ Hey all, [flymake-swi-prolog](https://git.sr.ht/~eshel/flymake-swi-prolog) is an Emacs package implementing a simple Flymake backend for SWI-Prolog, it provides diagnostics about Prolog source code in `prolog-mode` buffers. Here's how it may look when you write some code that makes no sense: [flymake-swi-prolog](https://preview.redd.it/1i26wiuvkrp81.png?width=834&format=png&auto=webp&s=ce7fa65cc9e9c1a9933af933717a3deae1486709) This is the first Emacs package I've authored, I use Emacs a lot but I haven't written a lot of Elisp outside of my config file before, so the implementation is mostly based on the [example backend from the Flymake manual](https://www.gnu.org/software/emacs/manual/html_node/flymake/An-annotated-example-backend.html). Any comments or suggestions are welcome! Under the hood, `flymake-swi-prolog` uses [diagnostics.pl](https://git.sr.ht/~eshel/diagnostics.pl), which is a tiny Prolog package I've written to expose the diagnosis performed by the SWI-Prolog built-in IDE in a way that is both human-readable and easy enough for me to consume from Elisp.
thesolitaire · 2022-03-27 06:00
nice, because the world needs more prolog! I wish I still got to work with it.
astoff1 · 2022-03-27 17:05
Are you passing the file name to the linter? Normally one should pass the buffer contents, via stdin, since Flymake doesn't wait for you to save the file to call the backends.
eshelyaron · 2022-03-27 19:28
Thank you for your comment, I actually pass both the buffer's contents via stdin and the file name via the command line, so on the Prolog side the file path can be used to resolve relative paths that occur in the source code. I did forget to pass the command line argument that tells the Prolog side to only read from stdin, which is fixed now :)
sylvain_soliman · 2022-03-28 11:04
I'm more of a fan of the LSP-based approach these days, but nice work!