Use UTF8 length on callee to align multiline arg list
Fixes the issue described here:
https://lists.sr.ht/~technomancy/fennel/%3Cb2c26bc9-f3fd-4aa7-802b-ece4096e2704@alterae.online%3E
Per an option mentioned in that discussion, utf8-len from fennel.view
was copied in. It's used as a fallback in slength if utf8 isn't
available.
Before patch:
(λ way-too-many-arguments [_first
_second
{: foo
: bar
: baz
: quux
:unused1 _
:unused2 _
:unused3 _
:unused4 _
& destructured}
another
last-param]
"Lambda with way too many arguments."
(.. "body omitted for " "brevity"))
After patch:
(λ way-too-many-arguments [_first
_second
{: foo
: bar
: baz
: quux
:unused1 _
:unused2 _
:unused3 _
:unused4 _
& destructured}
another
last-param]
"Lambda with way too many arguments."
(.. "body omitted for " "brevity"))
Explain rationale better; separate out formatting rules document.
Preserve original notation for numbers and strings.
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.
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.