[slime-devel] Inserting images into the REPL

Ariel Badichi abadichi at bezeqint.net
Mon Apr 14 21:04:38 UTC 2008


Hello,

What follows is a patch to SLIME-REPL-EMIT which allows a cool hack:
inserting images into the REPL.  I find it useful when experimenting
with graphics-related code.  CL code:

(defun insert-image-into-repl (filename)
  (swank::eval-in-emacs
   `(progn
      (slime-repl-emit
       (lambda ()
         (insert-image (create-image ,filename))
         (insert #\Newline)))
      :ok))
  (values))

(SLIME-ENABLE-EVALUATE-IN-EMACS needs to be true to make this work.)

Ariel

---

Index: slime.el
===================================================================
RCS file: /project/slime/cvsroot/slime/slime.el,v
retrieving revision 1.936
diff -u -r1.936 slime.el
--- slime.el	6 Apr 2008 09:58:17 -0000	1.936
+++ slime.el	14 Apr 2008 20:48:17 -0000
@@ -2555,13 +2555,17 @@
     (:repl-result (slime-repl-emit-result string))
     (t (slime-emit-string string target))))
 
-(defun slime-repl-emit (string)
-  ;; insert the string STRING in the output buffer
+(defun slime-repl-emit (thing)
+  "Insert THING into the output buffer if it is a string or, if
+it is a function, call it in the right context for insertion."
   (with-current-buffer (slime-output-buffer)
     (slime-with-output-end-mark 
-     (slime-insert-propertized '(face slime-repl-output-face
-                                      rear-nonsticky (face))
-                               string)
+     (etypecase thing
+       (string
+        (slime-insert-propertized '(face slime-repl-output-face
+                                         rear-nonsticky (face))
+                                  thing))
+       (function (funcall thing)))
      (set-marker slime-output-end (point))
      (when (and (= (point) slime-repl-prompt-start-mark)
                 (not (bolp)))




More information about the slime-devel mailing list