Page 1 of 1

wish: option for pretty-print

Posted: Sun Apr 01, 2018 7:41 am
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

Re: wish: option for pretty-print

Posted: Mon Apr 02, 2018 8:34 am
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