@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?
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?
thanks for getting back to me @sogaiu
No experience here with emacs char positions
I am throwing from position-in-range to avoid repeating the check in more than one place.
glad to hear the branch is working for you, you are an awesome pre alpha tester! :simple_smile:
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 🙂
likewise! lotsa fun! :simple_smile:
any idea how I could skip all whitespaces when parsing a file? I’m not interested in those for my current project
right now I’m removing them after the fact
hi @borkduke! Are you looking to delete all unnecessay whitespace from the zipper?
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.
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.
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.
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.
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
I’ll ask the main author of rewrite-clj for permission
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.
No, I’ve sent him an e-mail. He doesn’t seem to show much activity in public?
I’m guessing he’s busy with other stuff these days, but don’t know.