Skip to content

Instantly share code, notes, and snippets.

@nirved
Created July 19, 2020 15:26
Show Gist options
  • Save nirved/e59aa01f2cd6d75ca6d5dde08c037519 to your computer and use it in GitHub Desktop.
Save nirved/e59aa01f2cd6d75ca6d5dde08c037519 to your computer and use it in GitHub Desktop.
Displaying svg image in slime-repl
;; eval inside emacs:
(setq slime-enable-evaluate-in-emacs t)
;; in slime-repl:
(ql:quickload :cl-svg)
(let ((scene (svg:make-svg-toplevel 'svg:svg-1.1-toplevel :height 300 :width 300)))
(svg:draw scene (:rect :x 5 :y 5 :height 30 :width 30))
(svg:draw scene (:rect :x 40 :y 40 :height 30 :width 30)
:stroke "blue" :stroke-width 1 :fill "yellow")
(svg:draw scene (:rect :x 75 :y 75 :height 30 :width 30)
:fill "purple")
(let ((s (with-output-to-string (s)
(svg:stream-out s scene))))
(swank:eval-in-emacs `(slime-media-insert-image (create-image ,s 'svg t) "test"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment