1

I'm curious about this presentation in emacs:

SVG in emacs realtime

I could make it working, but refreshing the image manually, following this question and using the svg package, So I would try to do it in real time using ielm.

working circle

It seems that the problem is the major-mode image-mode with Imagemagick. If I use fundamental mode, it works, not well, but it works. In which mode should I open that buffer?

  • What is your question? – phils Nov 29 '18 at 10:42
  • I would like to create that in the ielm, and modify the svg in realtime, seeing the reuslts in emacs buffer – anquegi Nov 29 '18 at 10:45
  • 1
    Follow usage example in the commentary in svg.el, use svg-insert-image, the picture is updated in realtime. – xuchunyang Nov 29 '18 at 11:29
  • 1
    1.) For the first error, don't follow that SE question to write the svg data to disk then view it with Emacs. Simply create a fresh buffer and use svg-insert-image there. 2). For the second error, you need the newer version 0.1 of svg.el from Gnu Elpa, not the builtin one. – xuchunyang Nov 29 '18 at 13:26
  • 1
    Regarding my last comment, at least Emacs 26.1 actually provides newer version of svg.el than svg-0.1.el from Gnu Elpa, and it even has documentation (info "(elisp) SVG Images") – xuchunyang Nov 29 '18 at 17:04
3

Thanks to the comments of @xuchunyang, it was easy enough to figure and answer to this question just for the sake of completion. the easy way is open ielm (M-x ielm), and split the buufer in Two, then on one ielm do:

*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (require 'svg)
svg

ELISP> (find-file "test-buffer")
#<buffer test-buffer>
ELISP> ;; create the svg
ELISP> (setf svg (svg-create 400 400))
(svg
 ((width . 400)
  (height . 400)
  (version . "1.1")
  (xmlns . "http://www.w3.org/2000/svg")))

ELISP> (svg-insert-image svg)
((width . 400)
 (height . 400)
 (version . "1.1")
 (xmlns . "http://www.w3.org/2000/svg")
 (:image . #<marker at 1 in test-buffer>))

ELISP> (svg-circle svg 200 200 50)
nil
ELISP> (svg-rectangle svg 100 100 200 200)
nil
ELISP> svg
(svg
 ((width . 400)
  (height . 400)
  (version . "1.1")
  (xmlns . "http://www.w3.org/2000/svg")
  (:image . #<marker at 1 in test-buffer>))
 (circle
  ((cx . 200)
   (cy . 200)
   (r . 50)))
 (rect
  ((width . 200)
   (height . 200)
   (x . 100)
   (y . 100))))

the result is pretty awesome, not this draw, but to see how is easy is to create an svg archive in emacs and view the results

result

The svg package inuded in emacs is easy to read and to learn for use

ELISP> (info "(elisp) SVG Images")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.