rewrite-clj

https://github.com/clj-commons/rewrite-clj
2019-04-27T00:55:08.032100Z

@lee sorry i didn't respond sooner. it does seem like a good idea to indicate to the caller there is some issue with row / col being <= 0 -- that is at least easy to detect. it seems like it's more work to check whether a given col value is sensible as this depends on the row in question -- it is not clear to me whether this is worth the effort. perhaps it is enough to document that for col values that exceed the column boundary for a given row, the return value will be either "\n" (for all row except the last one) or nil (for the last row). on a side note, i forgot whether i mentioned this, but when working with emacs, i noticed there is a tendency to work with character positions for certain functions (e.g. shell-command-on-region) rather than row / col. this seemed to make certain sorts of computations easier. i haven't compared this approach in-depth to using row / col and wonder whether anyone else has....are you familiar with any such comparisons?

2019-04-27T00:58:04.034900Z

forgot to mention that i tried your updated branch -- it seems to work 🙂 i am not sure about the best place to throw from -- should it be position-in-range? or find-last-by-pos or both -- did you have some reasoning for your current choice?

lread 2019-04-27T00:58:59.035500Z

thanks for getting back to me @sogaiu

lread 2019-04-27T00:59:28.036200Z

No experience here with emacs char positions

lread 2019-04-27T01:02:00.038900Z

I am throwing from position-in-range to avoid repeating the check in more than one place.

lread 2019-04-27T01:03:02.040300Z

glad to hear the branch is working for you, you are an awesome pre alpha tester! :simple_smile:

2019-04-27T01:40:21.042100Z

thanks for the explanation. it's good to have you to talk to about rewrite-clj* -- i am finding it helpful and am enjoying the interaction 🙂

lread 2019-04-27T01:42:00.042800Z

likewise! lotsa fun! :simple_smile:

borkdude 2019-04-27T08:54:33.043300Z

any idea how I could skip all whitespaces when parsing a file? I’m not interested in those for my current project

borkdude 2019-04-27T08:55:04.043900Z

right now I’m removing them after the fact

lread 2019-04-27T09:44:47.049600Z

hi @borkduke! Are you looking to delete all unnecessay whitespace from the zipper?

lread 2019-04-27T12:31:59.051500Z

From rewrite-clj README: “rewrite-clj is a library offering mechanisms to easily rewrite Clojure/EDN documents in a whitespace- and comment-preserving way.” I have not noticed a way not to preserve whitespace at parse time.

borkdude 2019-04-27T12:51:28.052400Z

I first parse to nodes, then remove all whitespace nodes. I don’t even use the zippers that much, mostly processing the nodes by hand. Parsing takes about 40-50% of total time. Removing whitespace takes about 10%. Would be nice if that could be avoided.

borkdude 2019-04-27T12:53:37.053900Z

I just happen to like the output that the rewrite-clj parser gives me. I don’t know of another tool which does this currently, that is more configurable.

lread 2019-04-27T14:16:28.061200Z

That is an interesting use of rewrite-clj that had not occurred to me. Since preserving whitespace is in rewrite-clj’s primay goals, I am thinking it probably won’t have an option to skip whitespace at parse time.

borkdude 2019-04-27T14:22:20.061900Z

yeah, it seems to an assumption throughout the code base. maybe I should make a fork and tweak the parser, since that’s the only part I need from it

borkdude 2019-04-27T14:24:47.062300Z

I’ll ask the main author of rewrite-clj for permission

lread 2019-04-27T14:30:40.066500Z

Are you in contact with the author? I’d love to let him know what I am up to with rewrite-cljs. Once I release under clj-commons, if your tweaks are compatible, and of general interest, we should consider them.

borkdude 2019-04-27T14:31:14.066900Z

No, I’ve sent him an e-mail. He doesn’t seem to show much activity in public?

lread 2019-04-27T14:31:51.067700Z

I’m guessing he’s busy with other stuff these days, but don’t know.