[slime-devel] Re: REPL-specific printer control variables

Robert J. Macomber slime at rojoma.com
Wed May 24 14:18:33 UTC 2006


On Wed, May 24, 2006 at 10:25:45AM +0300, Nikodemus Siivola wrote:
>  1. *PRINT-LEVEL* &co are the right tools to use for affecting the
>     REPL. If your code assumes magic values of *PRINT-LEVEL* it is
>     more-or-less broken, and should bind them explicitly, for which
>     you will find WITH-STANDARD-IO-SYNTAX convenient.

Well, code I write at the REPL, inasmuch as it assumes anything at
all, will be assuming "default values" or "the values I just setf'd"
for the printer control things.  This is quick throwaway code, not
production stuff, or it'd go in a file and use w-s-i-s.  Anyway, the
point is, these things sometimes -- frequently enough that I got
sufficiently annoyed by it to write the patch -- will return a value
I'm not interested in but which takes a lot of space to print (this
happens pretty often when doing a quick image-manipulation with cl-gd
at the repl).  It's just a way to keep myself from kicking myself and
saying "idiot, you should've returned nil or (values) or something so
you wouldn't lose so much visual context".

That's why the default behavior is to behave as if this patch didn't
exist at all.  I did expect it would be nonintuitive and surprising
for the REPL printer to suddenly act differently from printer calls in
other places.

>  2. If this really really must go in, please let us make it 
>     *PRESENTATION-PRINT-ALIST* instead, and use a PROGV:

Ok.  New version attached.
-- 
Robert Macomber
slime at rojoma.com
-------------- next part --------------
Index: swank.lisp
===================================================================
RCS file: /project/slime/cvsroot/slime/swank.lisp,v
retrieving revision 1.378
diff -u -r1.378 swank.lisp
--- swank.lisp	12 May 2006 12:21:45 -0000	1.378
+++ swank.lisp	24 May 2006 13:34:27 -0000
@@ -100,6 +100,10 @@
     (*print-escape*           . t))
   "A set of printer variables used in the debugger.")
 
+(defvar *presentation-print-alist* '()
+  "Contains variables and values to be bound while printing the
+values produced by an evaluation at the listener.")
+
 (defvar *default-worker-thread-bindings* '()
   "An alist to initialize dynamic variables in worker threads.  
 The list has the form ((VAR . VALUE) ...).  Each variable VAR will be
@@ -2382,9 +2386,11 @@
 	(setq +++ ++  ++ +  + last-form)
         (cond ((eq *slime-repl-suppress-output* t) '(:suppress-output))
               (*record-repl-results*
-               `(:present ,(loop for x in values 
-                                 collect (cons (prin1-to-string x) 
-                                               (save-presented-object x)))))
+               (let ((bindings (reverse *presentation-print-alist*)))
+                 (progv (mapcar #'car bindings) (mapcar #'cdr bindings)
+                   `(:present ,(loop for x in values 
+                                  collect (cons (prin1-to-string x) 
+                                                (save-presented-object x)))))))
               (t 
                `(:values ,(mapcar #'prin1-to-string values))))))))
 


More information about the slime-devel mailing list