Hey,
I wanted to be able to display images in my SLIME repl, so that I could do stuff like http://collison.ie/img/google-charts.png. I played around with swank.lisp and slime.el for an hour, and hacked together something that mostly works. The code is ugly as sin, but I'm posting it here in case anyone wants to similarly subvert their SLIME installation. If there's any interest in having this be a part of the SLIME distribution, I'm happy to look at cleaning it up...
Patch against CVS slime at collison.ie/code/slime-pictures.patch.
When applied, test it out with something like:
(swank:make-picture :url "http://www.gnu.org/graphics/gnu-head.png" :type 'png)
Cheers,
Patrick
Cool!
It would be nice to be able to do something like this with vecto and CLNUPlot.
Patrick Collison wrote:
Hey,
I wanted to be able to display images in my SLIME repl, so that I could do stuff like http://collison.ie/img/google-charts.png. I played around with swank.lisp and slime.el for an hour, and hacked together something that mostly works. The code is ugly as sin, but I'm posting it here in case anyone wants to similarly subvert their SLIME installation. If there's any interest in having this be a part of the SLIME distribution, I'm happy to look at cleaning it up...
Patch against CVS slime at collison.ie/code/slime-pictures.patch.
When applied, test it out with something like:
(swank:make-picture :url "http://www.gnu.org/graphics/gnu-head.png" :type 'png)
Cheers,
Patrick _______________________________________________ slime-devel site list slime-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/slime-devel
Yes! I'm going to add it to my list...
On May 7, 2008, at 9:02 AM, Knut Olav Bøhmer wrote:
Cool!
It would be nice to be able to do something like this with vecto and CLNUPlot.
Patrick Collison wrote:
Hey,
I wanted to be able to display images in my SLIME repl, so that I could do stuff like http://collison.ie/img/google-charts.png. I played around with swank.lisp and slime.el for an hour, and hacked together something that mostly works. The code is ugly as sin, but I'm posting it here in case anyone wants to similarly subvert their SLIME installation. If there's any interest in having this be a part of the SLIME distribution, I'm happy to look at cleaning it up...
Patch against CVS slime at collison.ie/code/slime-pictures.patch.
When applied, test it out with something like:
(swank:make-picture :url "http://www.gnu.org/graphics/gnu- head.png" :type 'png)
Cheers,
Patrick _______________________________________________ slime-devel site list slime-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/slime-devel
-- Free Software Consultant Cell: +47 - 47 34 40 08 Phone: +47 - 21 53 69 00, Fax: +47 - 21 53 69 09 Addr: Slemdalsveien 70, PB 1 Vinderen, 0319 Oslo <logo_horizontal.png> _______________________________________________ slime-devel site list slime-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/slime-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM
Gary King gwking@metabang.com writes:
On May 7, 2008, at 9:02 AM, Knut Olav Bøhmer wrote:
Cool!
It would be nice to be able to do something like this with vecto and CLNUPlot.
http://www.freebits.de/users/tcr/tmp/vecto/INSTALL
-T.
"Patrick Collison" patrick@collison.ie writes:
I wanted to be able to display images in my SLIME repl, so that I could do stuff like http://collison.ie/img/google-charts.png. I played around with swank.lisp and slime.el for an hour, and hacked together something that mostly works. The code is ugly as sin, but I'm posting it here in case anyone wants to similarly subvert their SLIME installation. If there's any interest in having this be a part of the SLIME distribution, I'm happy to look at cleaning it up...
I, too, hacked something like that not long ago:
http://common-lisp.net/pipermail/slime-devel/2008-April/007264.html
A few days later I mutilated it to be a slime contrib (but still requiring the SLIME-REPL-EMIT change), which follows (don't ask about the license :). Because it receives a filename to display, it is more low-level than your interface. It's easy then to write a simple CL function to fetch and display and image (say, using Drakma).
(It's a git diff, I use the git://github.com/nablaone/slime mirror.)
Ariel
--- commit eaeac5d2067f561ec478d3946b6fcdea8018bebc Author: Ariel Badichi abadichi@bezeqint.net Date: Fri Apr 18 04:17:22 2008 +0300
Added slime-image contrib.
diff --git a/contrib/slime-image.el b/contrib/slime-image.el new file mode 100644 index 0000000..83f1f46 --- /dev/null +++ b/contrib/slime-image.el @@ -0,0 +1,17 @@ +;;; slime-image.el --- Insert images into the REPL +;; +;; Author: Ariel Badichi abadichi@bezeqint.net +;; +;; License: fuck-knows +;; +;;; Installation +;; +;; Add slime-image to your slime-setup call. + +(defun slime-image-init () + (add-hook 'slime-connected-hook 'slime-image-install)) + +(defun slime-image-install () + (slime-eval-async '(swank:swank-require :swank-image))) + +(provide 'slime-image) diff --git a/contrib/swank-image.lisp b/contrib/swank-image.lisp new file mode 100644 index 0000000..6b58c32 --- /dev/null +++ b/contrib/swank-image.lisp @@ -0,0 +1,18 @@ +(in-package #:swank) + +(defslimefun insert-image-into-repl (filename &optional (error t)) + "Insert the image in the file denoted by FILENAME into the REPL +buffer and return true. If the file does not exist, then either error +if ERROR is true, or return false otherwise." + (let ((probe (probe-file filename))) + (cond (probe + (eval-in-emacs + `(progn + (slime-repl-emit + (lambda () + (insert-image (create-image ,(namestring probe))) + (insert #\Newline))) + :ok)) + t) + (error (error "A file named ~S does not exist." filename)) + (t nil)))) diff --git a/slime.el b/slime.el index ceba26a..de1cd3c 100644 --- a/slime.el +++ b/slime.el @@ -2555,13 +2555,17 @@ hashtable `slime-output-target-to-marker'; output is inserted at this marker." (: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))) diff --git a/swank-loader.lisp b/swank-loader.lisp index 490d149..0431442 100644 --- a/swank-loader.lisp +++ b/swank-loader.lisp @@ -185,6 +185,7 @@ If LOAD is true, load the fasl file." swank-fancy-inspector swank-presentations swank-presentation-streams #+(or asdf sbcl) swank-asdf + swank-image ) "List of names for contrib modules.")
On Wed, May 7, 2008 at 2:29 PM, Ariel Badichi abadichi@bezeqint.net wrote:
"Patrick Collison" patrick@collison.ie writes:
I wanted to be able to display images in my SLIME repl, so that I could do stuff like http://collison.ie/img/google-charts.png. I played around with swank.lisp and slime.el for an hour, and hacked together something that mostly works. The code is ugly as sin, but I'm posting it here in case anyone wants to similarly subvert their SLIME installation. If there's any interest in having this be a part of the SLIME distribution, I'm happy to look at cleaning it up...
I, too, hacked something like that not long ago:
http://common-lisp.net/pipermail/slime-devel/2008-April/007264.html
Cool. Luke/Helmut, what say you to including something along these lines in SLIME? I suspect there may be many who'd find it useful -- since twittering about it yesterday, I've had a number of people contact me looking for the patch.
Cheers,
Patrick
"Patrick Collison" patrick@collison.ie writes:
Cool. Luke/Helmut, what say you to including something along these lines in SLIME? I suspect there may be many who'd find it useful -- since twittering about it yesterday, I've had a number of people contact me looking for the patch.
http://article.gmane.org/gmane.lisp.slime.devel/7299
On Wed, May 7, 2008 at 3:59 PM, Marco Baringer mb@bese.it wrote:
"Patrick Collison" patrick@collison.ie writes:
Cool. Luke/Helmut, what say you to including something along these lines in SLIME? I suspect there may be many who'd find it useful -- since twittering about it yesterday, I've had a number of people contact me looking for the patch.
Hmm. Would be interested to know if Helmut's stance has changed as a result of this work being independently done again.
Patrick
"Patrick Collison" patrick@collison.ie writes:
Hmm. Would be interested to know if Helmut's stance has changed as a result of this work being independently done again.
I don't like any of the implementations offered so far. I'd probably favor implementing this by extending the fancy-inspector page markup to handle images.
An implementation involving file names won't necessarily work in a remote setting. And as the protocol doesn't support binary transmission afaicr, it's necessary to resort to something like uuencode to stay absolutely portable---and all this counts as bloat.
-T.
* Patrick Collison [2008-05-07 17:05+0200] writes:
Hmm. Would be interested to know if Helmut's stance has changed as a result of this work being independently done again.
Well no. I don't think that SLIME needs support for pictures. But I'm willing to add enough hooks so that such features can be implemented (possibly as contrib package) without changing SLIME.
There is already swank:*listener-eval-function* and slime-write-string-function on the Emacs side. Do you need more?
Helmut.