popup-tip convert faces
Closed this issue · 4 comments
tigermonkey commented
Hi, I am trying to display some text with popup-tip. The text may contain italics or bold, but I want it to display with the tooltip face as the base, rather than the buffer's default.
(popup-tip #("foo bar" 0 3 (face bold) 3 4 nil 4 7 (face italic)) :nostrip t)
Can popup-tip
do this conversion or do I have to do the conversion myself?
syohex commented
popup
does not have such conversion now.
You need to define such faces and apply them as below.
(setq popup-tip-foreground (face-foreground 'popup-tip-face)
popup-tip-background (face-background 'popup-tip-face))
(defface my-bold
`((t (:weight bold :foreground ,popup-tip-foreground
:background ,popup-tip-background)))
"my bold")
(defface my-italic
`((t (:italic t :foreground ,popup-tip-foreground
:background ,popup-tip-background)))
"my italic")
(popup-tip (concat "foo "
(propertize "bar " 'face 'my-bold)
(propertize "baz" 'face 'my-italic))
:nostrip t)
tigermonkey commented
That didn't work for me but made me understand faces much better now:
(defface my-bold
`((t (:inherit popup-tip-face
:weight bold)))
"my bold"
:group 'popup)
(defface my-italic
`((t (:inherit popup-tip-face
:slant italic)))
"my italic"
:group 'popup)
(popup-tip (concat
"normal "
(propertize "italic" 'face 'my-italic)
(propertize " " 'face nil)
(propertize "bold" 'face 'my-bold))
:nostrip t)
EDIT: use :inherit
syohex commented
Thanks for the catch.
jcs090218 commented
Cool, I guess this issue is resolved?
Close this now! Feel free to reopen this if you find it useful.