From: Joseph Turner <joseph@ushin.org>
To: Emacs Devel Mailing List <emacs-devel@gnu.org>
Subject: Retain image properties after image-mode commands
Date: Sun, 03 Mar 2024 22:07:49 -0800 [thread overview]
Message-ID: <878r2ytqnx.fsf@ushin.org> (raw)
Hello!
I would like to use `image-mode' commands such as
`image-transform-set-scale' on non-file-backed images which have image
properties. That command internally calls `image-toggle-display-image',
which recontructs the image with `create-image', throwing away any
existing image properties.
A concrete example:
Evalute the following form to render an SVG image in an Emacs buffer:
(with-current-buffer (get-buffer-create "*image-properties-test*")
(let ((svg-string "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.43.0 (0)\n -->\n<!-- Title: orggraphview Pages: 1 -->\n<svg width=\"128pt\" height=\"128pt\"\n viewBox=\"0.00 0.00 127.59 127.59\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 123.59)\">\n<title>orggraphview</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-123.59 123.59,-123.59 123.59,4 -4,4\"/>\n<!-- a -->\n<g id=\"node1\" class=\"node\">\n<title>a</title>\n<g id=\"a_node1\"><a xlink:href=\"1\" xlink:title=\"Hover me!\">\n<ellipse fill=\"none\" stroke=\"black\" cx=\"59.79\" cy=\"-59.79\" rx=\"59.59\" ry=\"59.59\"/>\n<text text-anchor=\"middle\" x=\"59.79\" y=\"-56.09\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">Hover me!</text>\n</a>\n</g>\n</g>\n</g>\n</svg>\n")
(map '(((circle (85 . 85) . 80) "1" (help-echo "Surprise!"))))
(inhibit-read-only t))
(fundamental-mode)
(erase-buffer)
(insert-image (create-image svg-string 'svg t :map map) svg-string)
(image-mode)
(pop-to-buffer (current-buffer))))
Mouse over the circle in the center of the SVG to see the tooltip.
Then zoom in on the image: Interactively run `image-transform-set-scale'
by pressing "s s" then type the number 2 and press RET.
The image gets bigger, but now mousing over the circle has no effect.
How can I keep the mouse-over effect (the image :map property) after
running `image-mode' commands which reconstruct the image?
Thank you!!
Joseph
next reply other threads:[~2024-03-04 6:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 6:07 Joseph Turner [this message]
2024-03-05 16:34 ` Retain image properties after image-mode commands Juri Linkov
2024-03-05 17:10 ` Stephen Berman
2024-03-06 7:51 ` Joseph Turner
2024-03-08 7:33 ` Joseph Turner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878r2ytqnx.fsf@ushin.org \
--to=joseph@ushin.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).