File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 162
162
163
163
(deftype Indent [block relative-to offset start end]
164
164
(__repr__ [self]
165
- (str [(python/id block) relative-to offset])))
165
+ (str [:indent (python/id block) relative-to offset])))
166
166
167
167
(deftype Newline [block kind start end]
168
168
(__repr__ [self]
284
284
max-col (:max @writer)]
285
285
(and miser-width
286
286
max-col
287
- (>= (.-start-col (.-block token)) (- max miser-width))
287
+ (>= (.-start-col (.-block token)) (- max-col miser-width))
288
288
(emit-linear-nl? token section)))
289
289
;; TODO: figure out how to handle these newline types
290
290
:fill nil))
Original file line number Diff line number Diff line change 283
283
28
284
284
29)"] (match-ideref v))))))
285
285
286
+ (defmulti miser-dispatch type)
287
+
288
+ (defmethod miser-dispatch :default
289
+ [o]
290
+ (pr o))
291
+
292
+ (defmethod miser-dispatch basilisp.lang.interfaces/IPersistentVector
293
+ [o]
294
+ (pprint/pprint-logical-block :prefix "[" :suffix "]"
295
+ (pprint/print-length-loop [binding o]
296
+ (when (seq binding)
297
+ (pprint/pprint-logical-block
298
+ (pprint/write-out (first binding))
299
+ (when (next binding)
300
+ (.write *out* " ")
301
+ (pprint/pprint-newline :miser)
302
+ (pprint/write-out (second binding))))
303
+ (when-let [remaining (next (rest binding))]
304
+ (.write *out* " ")
305
+ (pprint/pprint-newline :linear)
306
+ (recur remaining))))))
307
+
308
+ (deftest pprint-miser-test
309
+ (binding [pprint/*print-pprint-dispatch* miser-dispatch]
310
+ (are [res margin] (= res (str/rtrim
311
+ (binding [pprint/*print-right-margin* margin]
312
+ (with-out-str
313
+ (pprint/pprint [:abcdefghijklmnop [:abcdefghijklmn :a]])))))
314
+ "[:abcdefghijklmnop
315
+ [:abcdefghijklmn
316
+ :a]]" 20
317
+ "[:abcdefghijklmnop
318
+ [:abcdefghijklmn :a]]" 25
319
+ "[:abcdefghijklmnop [:abcdefghijklmn :a]]" 50)))
320
+
286
321
(deftest pprint-print-level-test
287
322
(are [res plen expr] (= res (str/rtrim
288
323
(binding [*print-level* plen]
You can’t perform that action at this time.
0 commit comments