auto-complete / popup-el

Visual Popup Interface Library for Emacs
GNU General Public License v3.0
446 stars 96 forks source link

popup-tip convert faces #67

Closed tigermonkey closed 3 years ago

tigermonkey commented 10 years ago

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 10 years ago

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 10 years ago

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 10 years ago

Thanks for the catch.

jcs090218 commented 3 years ago

Cool, I guess this issue is resolved?

Close this now! Feel free to reopen this if you find it useful.