2

I heard that you could draw SVG in emacs using the svg.el library, but while i managed to get the right dependencies (I'm on ubuntu 19.10) and while compiling the latest version from the savannah.gnu repo work great, i couldn't see anything related to svg (svg.el) being used.(that is, i couldn't find it using M-x)

Though, from what i seen, it does work as i managed to install svg-clock but, nothing else show up in the M-x prompt about svg...

And yes, i also added imagemagick support to emacs, but no dice.

Additional details: I'm also using lucid instead of the gtk gui. Here the full configure flags i used ./configure --with-x-toolkit=lucid --with-xml2 --with-xft --with-libotf --with-imagemagick --with-rsvg

Basically i want either examples of how to use the svg.el (mostly so i can check if it's actually being used, or to check if it wasn't meant to be launched using M-x)

Lastly, i did used (image-type-available-p 'svg) to check whether it was available or not, and it was indeed...it just didn't appear in the prompt of M-x.

1 Answer 1

3

The SVG library is a library for programmatic generation of SVG images. Check out the source code of svg-clock.el for an example of how to use it: http://git.savannah.gnu.org/cgit/emacs/elpa.git/tree/packages/svg-clock/svg-clock.el

Here's a simplified example you can evaluate in the scratch buffer:

(require 'svg)

(let ((buffer "*svg-test*")
      (width 200)
      (height 100))
  (with-current-buffer (get-buffer-create buffer)
    (let (buffer-read-only)
      (erase-buffer)
      (let ((svg (svg-create width height)))
        (svg-gradient svg "bg" 'linear '((0 . "#000") (100 . "#fff")))
        (svg-rectangle svg 0 0 width height :gradient "bg")
        (svg-insert-image svg))
      (special-mode)))
  (display-buffer buffer))
1
  • Thanks, didn't thought of doing this! Commented May 13, 2020 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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