File tree Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Original file line number Diff line number Diff line change 38
38
(defn- replace-with-spaces
39
39
" Replace the given reader macro node with spaces."
40
40
[zloc]
41
- (let [w (count ( with-out-str ( prn/print-edn (z/node zloc)) ))]
41
+ (let [w (prn/estimate-length (z/node zloc))]
42
42
(-> zloc (z/prepend-space w) z/remove)))
43
43
44
44
(defn- remove-reader-macro
63
63
64
64
(defn cljx-walk
65
65
" Replace all occurences of profile reader macros."
66
- [active-profiles root ]
66
+ [root active-profiles]
67
67
(loop [loc root]
68
68
(if-let [mloc (z/find loc z/next cljx-macro?)]
69
69
(recur (handle-reader-macro active-profiles mloc))
70
70
loc)))
71
71
72
72
; ; ## Test
73
73
74
- (comment
75
- (def data
76
- (z/edn
77
- (p/parse-string
78
- " (defn my-inc\n [x]\n #+debug (println \" inc: x =\" x #-nomark \" [debug]\" )\n (+ x 1))" )))
74
+ (defn run-cljx-test
75
+ [profiles]
76
+ (let [data (z/of-string " ;; Test it!\n (defn my-inc\n [x]\n #+debug (println \" inc: x =\" x #-nomark \" [debug]\" )\n (+ x 1))" )]
77
+ (println " Original Code:" )
78
+ (z/print-root data)
79
+ (println " \n " )
79
80
80
- (println " Original Code:" )
81
- (-> data z/root prn/print-edn)
82
- (println " \n " )
83
-
84
- (println " Processed Code:" )
85
- (-> (cljx-walk #{" debug" " nomark" } data) z/root prn/print-edn)
86
- (println ))
81
+ (println " Processed Code:" )
82
+ (-> data (cljx-walk (or profiles #{" debug" " nomark" })) z/print-root)
83
+ (println )))
You can’t perform that action at this time.
0 commit comments