@borkdude @lee i've put together the sample discussed before (https://clojurians.zulipchat.com/#narrow/stream/180378-slack-archive/topic/rewrite-clj/near/165811770): https://github.com/sogaiu/adorn -- the focus was on getting something working, so as far as functionality is concerned, there is as yet nothing beyond applying the inline def transformation, but there are sample wrappers for atom, emacs, and vscode. on a possibly related note, i noticed: https://github.com/borkdude/clj-kondo/issues/145#issuecomment-490905418 and wonder if there is a possible fit.
@sogaiu interesting, curious to see how that plays out.
@sogaiu, kudos to you for not only trying this idea out, but also presenting it so well!
thanks. just hoping some improvement to the situation can come about.
@lee i was trying to remove metadata and had some difficulties initially. it appears that (at least in some cases) even if one replaces a metadata node with a node for the contained form (w/o the metadata map), the metadata is retained -- presumably because the contained form has the metadata living on it.
will post some example code
given:
(require '[rewrite-clj.zip :as rz])
(def comment-form-with-meta-idea-str
(str "(comment\n"
"\n"
" ^{:ael/expected 0 :ael/name \"simple subtraction\"}\n"
" (- 1 1)\n"
")\n"))
the following retains the metadata:
(-> (rz/of-string comment-form-with-meta-idea-str)
(rz/prewalk (fn [zloc]
(when (= (rz/tag zloc) :meta)
(let [map-zloc (rz/down zloc)]
(contains? (rz/sexpr map-zloc)
:ael/expected))))
(fn [zloc]
(-> zloc
rz/down
rz/right)))
rz/string)
the following successfully removes the metadata:
(-> (rz/of-string comment-form-with-meta-idea-str)
(rz/prewalk (fn [zloc]
(when (= (rz/tag zloc) :meta)
(let [map-zloc (rz/down zloc)]
(contains? (rz/sexpr map-zloc)
:ael/expected))))
(fn [zloc]
(rz/edit zloc
(fn [expr]
(with-meta expr {})))))
rz/string)
i was surprised, but do you think the current behavior makes sense / is inevitable?
Thanks @sogaiu, I shall have a look sometime over the next few days.
thanks!