wish: option for pretty-print

Q&A's, tips, howto's
Locked
HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

wish: option for pretty-print

Post by HPW »

Hello Lutz,

I had a wish for improving pretty-print.
Idea: I had problems in reading complex, nested lists which were saved with default pretty-print.
The problem is that on the first line are several list-items and on the following line one list per line.
For simple list it is pretty enough to be readable.
When symbols gets longer and more complex lists, I would like to see an option to use open-paranthese as line-seperators. The option could be activated by using a "(" instead of an integer.
Each open-paranthese would increase indent and the corrosponding close paranthese would decrease.
Sample-Call:

Code: Select all

(pretty-print "(" " " "%1.16g")
Sample Output:

Code: Select all

(set 'Symbolname 
'("MainItem" 
  ("Item1" "Value1") 
  ("Item2" "Value2") 
  ("Item3" "Value3") 
  ("Item4" "Value4") 
  ("Sublst" 
   ("SubItem1" "SubValue1") 
   ("SubItem1" "SubValue1") 
   ("SubItem1" "SubValue1") 
   ("SubList" 
    ( 
     ("SubListItem1" "SubListValue1") 
     ("SubListItem1" "SubListValue1") 
     ("SubListItem1" "SubListValue1") 
    ) 
   ) 
  ) 
 ) 
) 
What do think?

Regards
Hans-Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Re: wish: option for pretty-print

Post by HPW »

Hello,

My wish is the option for the lazy newlisp user. ;-)
For now I wrote my own special function to traverse the listtree and convert it to a stringstream.
The stringstream gets written to disk with write-file.
Then I have the control about indention and dynamic comments.
Still in love with newlisp.

Regards
Hans-Peter

Locked