[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

SLIME REPL: Pretty-printing the value of an expression?

Elena

2/7/2016 2:01:00 PM

How can you make the SLIME REPL pretty-print the value of expressions? Thank you.
11 Answers

Elena

2/7/2016 2:23:00 PM

0

On Sunday, February 7, 2016 at 3:00:54 PM UTC+1, Elena wrote:
> How can you make the SLIME REPL pretty-print the value of expressions? Thank you.

I am talking about expressions that are entered at the REPL, not expressions in a buffer, where C-c C-p (slime-pprint-eval-last-expression) would be the solution.

Antsan

2/7/2016 7:23:00 PM

0

I'm not sure what you mean. Can you give an example interaction?

Elena

2/7/2016 8:11:00 PM

0

On Sunday, February 7, 2016 at 8:23:23 PM UTC+1, Antsan wrote:
> I'm not sure what you mean. Can you give an example interaction?

Instead of this:

CL-USER> (do-something arg1 arg2)
((:RESULT . "success") (:SESSION-ID . "b4678adb2d68") (:HANDLE . 1836618159) (:VALUE . "none"))

I would like something like this:

CL-USER> (do-something arg1 arg2)
((:RESULT . "success")
(:SESSION-ID . "b4678adb2d68")
(:HANDLE . 1836618159)
(:VALUE . "none"))

Thank you.

Pascal J. Bourguignon

2/7/2016 8:27:00 PM

0

Elena <egarrulo@gmail.com> writes:

> On Sunday, February 7, 2016 at 8:23:23 PM UTC+1, Antsan wrote:
>> I'm not sure what you mean. Can you give an example interaction?
>
> Instead of this:
>
> CL-USER> (do-something arg1 arg2)
> ((:RESULT . "success") (:SESSION-ID . "b4678adb2d68") (:HANDLE . 1836618159) (:VALUE . "none"))
>
> I would like something like this:
>
> CL-USER> (do-something arg1 arg2)
> ((:RESULT . "success")
> (:SESSION-ID . "b4678adb2d68")
> (:HANDLE . 1836618159)
> (:VALUE . "none"))
>
> Thank you.

Set *print-right-margin* and *print-pretty*:

cl-user> (setf *print-right-margin* 72 *print-pretty* t)
t
cl-user> '((:RESULT . "success") (:SESSION-ID . "b4678adb2d68") (:HANDLE . 1836618159) (:VALUE . "none"))
((:result . "success") (:session-id . "b4678adb2d68")
(:handle . 1836618159) (:value . "none"))
cl-user> (setf *print-right-margin* 40 *print-pretty* t)
t
cl-user> '((:RESULT . "success") (:SESSION-ID . "b4678adb2d68") (:HANDLE . 1836618159) (:VALUE . "none"))
((:result . "success")
(:session-id . "b4678adb2d68")
(:handle . 1836618159)
(:value . "none"))
cl-user>

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

Antsan

2/7/2016 8:54:00 PM

0

Am Sonntag, 7. Februar 2016 21:26:59 UTC+1 schrieb informatimago:
> Elena <egarrulo@gmail.com> writes:
>
> > On Sunday, February 7, 2016 at 8:23:23 PM UTC+1, Antsan wrote:
> >> I'm not sure what you mean. Can you give an example interaction?
> >
> > Instead of this:
> >
> > CL-USER> (do-something arg1 arg2)
> > ((:RESULT . "success") (:SESSION-ID . "b4678adb2d68") (:HANDLE . 1836618159) (:VALUE . "none"))
> >
> > I would like something like this:
> >
> > CL-USER> (do-something arg1 arg2)
> > ((:RESULT . "success")
> > (:SESSION-ID . "b4678adb2d68")
> > (:HANDLE . 1836618159)
> > (:VALUE . "none"))
> >
> > Thank you.
>
> Set *print-right-margin* and *print-pretty*:
>
> cl-user> (setf *print-right-margin* 72 *print-pretty* t)
> t
> cl-user> '((:RESULT . "success") (:SESSION-ID . "b4678adb2d68") (:HANDLE . 1836618159) (:VALUE . "none"))
> ((:result . "success") (:session-id . "b4678adb2d68")
> (:handle . 1836618159) (:value . "none"))
> cl-user> (setf *print-right-margin* 40 *print-pretty* t)
> t
> cl-user> '((:RESULT . "success") (:SESSION-ID . "b4678adb2d68") (:HANDLE . 1836618159) (:VALUE . "none"))
> ((:result . "success")
> (:session-id . "b4678adb2d68")
> (:handle . 1836618159)
> (:value . "none"))
> cl-user>
>
> --
> __Pascal Bourguignon__ http://www.informat...
> "The factory of the future will have only two employees, a man and a
> dog. The man will be there to feed the dog. The dog will be there to
> keep the man from touching the equipment." -- Carl Bass CEO Autodesk

I guess there is no variable that forces to print a newline after any
parenthesis that isn't followed by another one?

Pascal J. Bourguignon

2/7/2016 8:55:00 PM

0

Antsan <thomas.bartscher@gmail.com> writes:

> I guess there is no variable that forces to print a newline after any
> parenthesis that isn't followed by another one?

That would be *print-pprint-dispatch*, but more knowledge is needed to
configure it properly. I don't have it.


--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

Antsan

2/7/2016 9:09:00 PM

0

Am Sonntag, 7. Februar 2016 21:55:11 UTC+1 schrieb informatimago:
> Antsan <thomas.bartscher@gmail.com> writes:
>
> > I guess there is no variable that forces to print a newline after any
> > parenthesis that isn't followed by another one?
>
> That would be *print-pprint-dispatch*, but more knowledge is needed to
> configure it properly. I don't have it.
>
>
> --
> __Pascal Bourguignon__ http://www.informat...
> "The factory of the future will have only two employees, a man and a
> dog. The man will be there to feed the dog. The dog will be there to
> keep the man from touching the equipment." -- Carl Bass CEO Autodesk

This variable contains a Pretty Print Dispatch Table, which chooses a pretty
printing function based on the object. Seems like this won't really help me
with arbitrary objects being printed with a closing parenthesis.

Antsan

2/7/2016 9:10:00 PM

0

Am Sonntag, 7. Februar 2016 22:08:38 UTC+1 schrieb Antsan:
> Am Sonntag, 7. Februar 2016 21:55:11 UTC+1 schrieb informatimago:
> > Antsan <thomas.bartscher@gmail.com> writes:
> >
> > > I guess there is no variable that forces to print a newline after any
> > > parenthesis that isn't followed by another one?
> >
> > That would be *print-pprint-dispatch*, but more knowledge is needed to
> > configure it properly. I don't have it.
> >
> >
> > --
> > __Pascal Bourguignon__ http://www.informat...
> > "The factory of the future will have only two employees, a man and a
> > dog. The man will be there to feed the dog. The dog will be there to
> > keep the man from touching the equipment." -- Carl Bass CEO Autodesk
>
> This variable contains a Pretty Print Dispatch Table, which chooses a pretty
> printing function based on the object. Seems like this won't really help me
> with arbitrary objects being printed with a closing parenthesis.

I just realized that this would be stupid either way. Inserting newlines into
the printed output of strings wouldn't be desirable at all.

The problem still remains, of course.

Pascal J. Bourguignon

2/7/2016 11:13:00 PM

0

Antsan <thomas.bartscher@gmail.com> writes:

> Am Sonntag, 7. Februar 2016 21:55:11 UTC+1 schrieb informatimago:
>> Antsan <thomas.bartscher@gmail.com> writes:
>>
>> > I guess there is no variable that forces to print a newline after any
>> > parenthesis that isn't followed by another one?
>>
>> That would be *print-pprint-dispatch*, but more knowledge is needed to
>> configure it properly. I don't have it.
>
> This variable contains a Pretty Print Dispatch Table, which chooses a pretty
> printing function based on the object. Seems like this won't really help me
> with arbitrary objects being printed with a closing parenthesis.

Most closing parentheses still come from lists and vectors.
Even more closing parentheses are displayed inside lists and vectors!
In the example given there were only lists.

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

Elena

2/8/2016 8:07:00 AM

0

On Sunday, February 7, 2016 at 9:26:59 PM UTC+1, informatimago wrote:
> Set *print-right-margin* and *print-pretty*:
>
> cl-user> (setf *print-right-margin* 72 *print-pretty* t)
> t
> cl-user> '((:RESULT . "success") (:SESSION-ID . "b4678adb2d68") (:HANDLE . 1836618159) (:VALUE . "none"))
> ((:result . "success") (:session-id . "b4678adb2d68")
> (:handle . 1836618159) (:value . "none"))
> cl-user> (setf *print-right-margin* 40 *print-pretty* t)
> t
> cl-user> '((:RESULT . "success") (:SESSION-ID . "b4678adb2d68") (:HANDLE . 1836618159) (:VALUE . "none"))
> ((:result . "success")
> (:session-id . "b4678adb2d68")
> (:handle . 1836618159)
> (:value . "none"))
> cl-user>

That is interesting, but it would require me to change *print-right-margin* for every expression.

Isn't there a way to "intercept" the value that SLIME is about to print and pass it through an external pretty printer?