~technomancy/fnlfmt

Explain rationale better; separate out formatting rules document.
Preserve original notation for numbers and strings.
Update to Fennel 1.5.1
72ab426d — Michelle S 3 months ago
Replace `lambda` keyword with literal `λ` symbol

This commit causes lambda forms using the `lambda` keyword to be
re-written using the `λ` symbol, as described in this mailing list
entry:

https://lists.sr.ht/~technomancy/fennel/%3C2B629755-0AC0-49A3-A7DD-096350E33BF2@gmail.com%3E

This commit also introduces a test to verify the above functionality.
Bump to 0.3.3-dev
Install fnlfmt.lua as well.
Use new changed detection in --check as well.
Catch a local reference that didn't get renamed.
Prevent unnecessary writes with --fix

in order to allow tooling around fnlfmt to work right
Fix a bug from binding tables that come from arrow forms.
Fix a bug where multi-line callees would fail to reset start-indent.
Add changelog entry.
Fix --check option on PUC Lua 5.1

On PUC Lua 5.1, os.exit doesn't accept boolean.
Add option --check to check if files are formatted

On Sun, Mar 3, 2024 at 2:48 AM Phil Hagelberg <phil@hagelb.org> wrote:

> > +(fn check-files [filenames]
> > +  (let [ok? (accumulate [ok? true _ filename (pairs filenames)]
> > +              (and ok? (check-file filename)))]
> > +    (if ok?
> > +        (do
> > +          (io.stderr:write "All files are formatted.\n")
> > +          (os.exit true))
> > +        (os.exit false))))

> I think the `accumulate' is probably not necessary, since the failing
> branch exits already. Why not just a normal `each' over `check-file'
> similar to the `fix' loop? Moving the `os.exit' into `check-file' would
> make that simpler.

Thanks for your review. I've noticed that the above code was incorrect.
I intended to check all files, output warning for each non-formatted
file, and finally fail if any of them is not formatted. However, the
`(and ok? ...)` form skips remaining checks after finding the first
non-formatted file. Checking all files should be better than exiting
earlier IMHO.

So, I've fixed it in this v2 patch. Still using `accumulate` but
something like below might be clearer.

```fennel
(fn check-files [filenames]
  (var ok? true)
  (each [_ filename (ipairs filenames)]
    (when (not (check-file filename))
      (set ok? false)))
  (os.exit ok?))
```

> Its probably better to not emit any output if the check succeeds.

Removed output to stderr if all checks succeed.
Allow CLI to fix multiple files
bugfix: remove extra trailing space from CLI output

The `format-file` function in fnlfmt.fnl inserts an additional "" before
joining everything into lines, so using `print` to output it in cli.fnl
was causing an extraneous newline at the end.
Add check target to makefile.
Add uninstall target.
Next