rougier / svg-lib

Emacs SVG libraries for creatings tags, icons and bars
GNU General Public License v3.0
343 stars 31 forks source link

`svg-lib-concat` error #19

Closed mpardalos closed 2 years ago

mpardalos commented 2 years ago

Using svg-lib-concat gives an error. Evaluating the following elisp in an otherwise empty scratch buffer:

(insert-image (svg-lib-concat (svg-lib-tag "A") (svg-lib-tag "B"))) 

Gives this error

insert-image: Not an image: (svg ((width . 40) (height . 18.900000000000002) (version . 1.1) (xmlns . http://www.w3.org/2000/svg) (xmlns:xlink . http://www.w3.org/1999/xlink))   (rect ((width . 20) (height . 18.900000000000002) (x . 0.0) (y . 0) (rx . 3) (fill . #000000)))   (rect ((width . 18) (height . 16.900000000000002) (x . 1.0) (y . 1.0) (rx . 2.0) (fill . #ffffff)))   (text ((y . 13) (x . 6.0) (fill . #000000) (font-size . 13) (font-weight . 400) (font-family . DejaVu Sans Mono))  A)   (rect ((width . 20) (height . 18.900000000000002) (x . 0.0) (y . 0) (rx . 3) (fill . #000000) (transform . translate(20.000000,0))))   (rect ((width . 18) (height . 16.900000000000002) (x . 1.0) (y . 1.0) (rx . 2.0) (fill . #ffffff) (transform . translate(20.000000,0))))   (text ((y . 13) (x . 6.0) (fill . #000000) (font-size . 13) (font-weight . 400) (font-family . DejaVu Sans Mono) (transform . translate(20.000000,0)))  B))
mpardalos commented 2 years ago

I just realised the error. svg-lib-concat returns the svg args, not and svg "object" (?) It is meant to be given to svg-image or svg-lib-image. So, the following works:

(insert-image (svg-lib--image (svg-lib-concat (svg-lib-tag "A") (svg-lib-tag "B"))))

I don't know whether this is intended or an oversight, so I'm leaving the issue open.

rougier commented 2 years ago

This is on purpose yes (this is what allows concatenation) and user is responsible for display by calling svg-image.

mpardalos commented 2 years ago

Alright then. Closing since this is intentional.