~technomancy/fnlfmt

14e1bcce98da58942bc743cda69f28e1013e5c71 — Phil Hagelberg a month ago 78a40a6 master
Fix missing newline in anonymous fns.
2 files changed, 11 insertions(+), 7 deletions(-)

M fnlfmt.fnl
M macrodebug.fnl
M fnlfmt.fnl => fnlfmt.fnl +11 -4
@@ 51,7 51,8 @@ should continue looking to previous lines."
;; aren't on this list are indented like normal function calls.
(local body-specials {"let" true "fn" true "lambda" true "λ" true "when" true
                      "do" true "eval-compiler" true "for" true "each" true
                      "while" true "macro" true "match" true "doto" true})
                      "while" true "macro" true "match" true "doto" true
                      "with-open" true})

(fn remove-comment [line in-string? pos]
  (if (< (# line) pos) line


@@ 145,9 146,15 @@ looked up in the table of lines. Returns the column number to indent to."
      (- (# node) 1)
      (# node)))

(fn start-for [[callee]]
  (. {:fn 4 :match 3 :do 2 :let 3 :when 3 :if 3
      :while 3 :each 3 :for 3} (tostring callee)))
(fn anonymous-fn? [[callee name-org-arglist]]
  (and (= :fn (tostring callee))
       (not (match (getmetatable name-org-arglist)
              [which] (= which :SYMBOL)))))

(fn start-for [form]
  (if (anonymous-fn? form) 3
      (. {:fn 4 :match 3 :do 2 :let 3 :when 3 :if 3
          :while 3 :each 3 :for 3} (tostring (. form 1)))))

(fn add-newlines [idx node parent]
  (when (= :table (type node))

M macrodebug.fnl => macrodebug.fnl +0 -3
@@ 4,9 4,6 @@

(local *macros* {})

;; internal utils
(fn warn [msg ...] (io.stderr:write (.. "Warning: " msg "\n")) ...)

;; macros

(fn *macros*.pretty-macrodebug [expr return-string?]