Skip to content

Commit 947bc40

Browse files
committed
Marginally improved sexp output.
1 parent 59f2ca0 commit 947bc40

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

print_sexp.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def initialize opts = {}
1111
@nest = 0
1212
@indent = 2
1313
@col = 0
14-
@maxcol = 140
15-
@brk = 105 # @maxcol * 3 / 4
14+
@maxcol = 160
15+
@brk = 120
1616
@line = 0
1717

1818
@prune = opts[:prune]
@@ -25,6 +25,7 @@ def indent
2525

2626
def print str
2727
str = str.to_s
28+
str = str.gsub("\n","\\n")
2829
if @col > @maxcol
2930
puts
3031
end
@@ -55,7 +56,9 @@ def print_tree(data, out = STDOUT)
5556
end
5657

5758
def print_node node, nest = 0
58-
if node.is_a?(Array)
59+
if node.respond_to?(:print_node)
60+
node.print_node(self, nest)
61+
elsif node.is_a?(Array)
5962
# FIXME: Changed from @maxcol * 0.7 as compiler currently does not
6063
# support Float.
6164
puts if @col > @brk or

0 commit comments

Comments
 (0)