Fork me on GitHub
#rewrite-clj
<
2019-04-27
>
sogaiu00:04:08

@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?

sogaiu00:04:04

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?

lread00:04:59

thanks for getting back to me @sogaiu

lread00:04:28

No experience here with emacs char positions

lread01:04:00

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

lread01:04:02

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

sogaiu01:04:21

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 🙂

lread01:04:00

likewise! lotsa fun! simple_smile

borkdude08:04:33

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

borkdude08:04:04

right now I’m removing them after the fact

lread09:04:47

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

lread12:04:59

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.

borkdude12:04:28

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.

borkdude12:04:37

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.

lread14:04:28

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.

borkdude14:04:20

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

borkdude14:04:47

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

lread14:04:40

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.

borkdude14:04:14

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

lread14:04:51

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