wish: option for pretty-print

Q&A's, tips, howto's

wish: option for pretty-print

Postby HPW » Sun Apr 01, 2018 7:41 am

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: 1352
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Re: wish: option for pretty-print

Postby HPW » Mon Apr 02, 2018 8:34 am

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
HPW
 
Posts: 1352
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests