[slime-devel] Better way to get pretty print output with ABCL?

Mark Evenson evenson at panix.com
Mon May 23 15:16:34 UTC 2011


SLIME wraps in ABCL in a manner that doesn't use the TOP-LEVEL:REPL 
function so one doesn't get pretty printed output by default.

If I define SWANK::PRESENT-REPL-RESULTS-WITH-PPRINT as below, and bind 
it as the value of SWANK::*SEND-REPL-RESULTS-FUNCTION*, the the pretty 
printer is used for ABCL output under SLIME.

But I can't just stick this in the "~/.swank.lisp" file, as the value of 
swank::*send-repl-results-function* gets reset when 
contrib/swank-presentations.lisp is loaded making me think "I'm doing it 
wrong."

Is the ABCL/SLIME implementation somehow wrong in not using the 
TOP-LEVEL:REPL routines for evaluation?

How does one configure contrib contributions if not in "~/.swank.lisp"?

Does ABCL need to be fixed here, or SLIME, or both?


(defun present-repl-results-with-pprint (values)
   ;; Override a function in swank.lisp, so that
   ;; presentations are associated with every REPL result.
   (labels ((pprint-value (value)
              (let ((pprint-results (with-output-to-string (s) (pprint 
value s))))
                (subseq pprint-results 1))) ;; Strip preceding newline 
of pprint
            (send (value)
              (let ((id (and *record-repl-results*
                           (save-presented-object value))))
	     (send-to-emacs `(:presentation-start ,id :repl-result))
	     (send-to-emacs `(:write-string ,(pprint-value value)
					    :repl-result))
	     (send-to-emacs `(:presentation-end ,id :repl-result))
	     (send-to-emacs `(:write-string ,(string #\Newline)
					    :repl-result)))))
     (fresh-line)
     (finish-output)
     (if (null values)
         (send-to-emacs `(:write-string "; No value" :repl-result))
         (mapc #'send values))))



-- 
"A screaming comes across the sky.  It has happened before, but there
is nothing to compare to it now."





More information about the slime-devel mailing list