This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-27
Channels
- # beginners (56)
- # calva (61)
- # cider (16)
- # clara (7)
- # cljdoc (2)
- # cljs-dev (2)
- # cljsrn (1)
- # clojure (144)
- # clojure-spec (23)
- # clojure-uk (5)
- # clojurescript (9)
- # clojureverse-ops (5)
- # community-development (4)
- # cursive (18)
- # datomic (15)
- # docs (6)
- # jackdaw (2)
- # nrepl (10)
- # nyc (2)
- # off-topic (18)
- # rewrite-clj (20)
- # shadow-cljs (31)
@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?
I am throwing from position-in-range to avoid repeating the check in more than one place.
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 🙂
any idea how I could skip all whitespaces when parsing a file? I’m not interested in those for my current project
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