Reputation: 670
I would like to display HTML with bold and italic text in Emacs tooltips. The solution I am trying is like this:
(let ((html "regular <b>bold</b> regular <i>italic</i> regular\n")
(bufname "* render-html-tmp*"))
(with-current-buffer (get-buffer-create bufname)
(erase-buffer)
(insert html)
(shr-render-region (point-min) (point-max))
(tooltip-show (buffer-string))))
In the * render-html-tmp*
buffer the bold and italic text show up all right, but in the tooltip all the five words are in plain regular text, without bold or italic. Changing the value of x-gtk-use-system-tooltips
has no effect.
At the same time, when I go to the end of the * render-html-tmp*
buffer and do (insert (buffer-string))
there, or copy the buffer contents into the kill ring and yank it into a new buffer, the bold and italic attributes do show up correctly in the inserted or yanked text. So my basic idea should be right, and I am at my wit's end trying to figure out why I am not seeing these attributes in the tooltip.
What's going on, and how to make the bold and italic text show up in the tooltip?
Upvotes: 0
Views: 350
Reputation: 6412
tooltip-show
overrides the face property of the string that is passed into it and replaces it with its own tooltip
property:
(x-show-tip (propertize text 'face 'tooltip)
(selected-frame)
params
tooltip-hide-delay
tooltip-x-offset
tooltip-y-offset))
...
As the OP mentions in a comment, defining a modified tooltip-show
to pass text
directly to x-show-tip
instead of doing the (propertize text ...)
and calling that from his code resolves the problem.
Upvotes: 1