kkinnear / zprint

Executables, uberjar, and library to beautifully format Clojure and Clojurescript source code and s-expressions.
MIT License
554 stars 47 forks source link

Aliasing a function to another in :fn-map does not work on namespaced function calls #276

Closed miridius closed 1 year ago

miridius commented 1 year ago

I think this is best explained with an example:

zprint options:

{:fn-map {"dog" "cat"}}

Input:

(cat x y z)
(my/cat x y z)
(dog x y z)
(my/dog x y z)

Output:

(cat x
     y
     z)
(my/cat x
        y
        z)
(dog x
     y
     z)
(my/dog x y z)

As you can see, my/dog does not get formatted the same way as cat, even though it should according to the options.

miridius commented 1 year ago

Note: changing the options to {:fn-map {"dog" "cat" "my/dog" "cat"}} solves this (as a workaround)

kkinnear commented 1 year ago

Yes, I can reproduce this. Thanks for the succinct example. I have found and fixed this problem -- some missing code when I added the aliasing capability. It will be fixed in 1.2.4. Thanks for creating your own workaround! I appreciate the issue, and it is interesting to see that someone actually is interested in using the aliasing capability too. Thanks again!

zprint.core=> (zprint-file-str i276 "x" {:fn-map {"dog" "cat"}})
"(cat x\n     y\n     z)\n(my/cat x\n        y\n        z)\n(dog x\n     y\n     z)\n(my/dog x\n        y\n        z)\n"
zprint.core=> (print *1)
(cat x
     y
     z)
(my/cat x
        y
        z)
(dog x
     y
     z)
(my/dog x
        y
        z)
kkinnear commented 1 year ago

This was fixed in 1.2.4.