Subject: Re: bug#65632: 30.0.50; Proposal to improve `faces--attribute-at-point'.

From: Eli Zaretskii <[email-masked]>
Date: Wed, 30 Aug 2023 22:22:50 +0300

> Cc: [email-masked]
> Date: Wed, 30 Aug 2023 21:35:11 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> > ;; Display "TEST" in red, bold, italic on yellow background.
> > (insert
> >   (propertize
> >    "TEST" 'font-lock-face
> >    '(bold ((:background "yellow") "italic"
> >            ((foreground-color . "red") underline)))))
> 
> This is not a valid face, AFAIU.  That it works is sheer luck (because
> Emacs is very lenient with this stuff).  The correct face definition
> for what you want is this (see 'set-face-attribute's doc string):
> 
>   (insert
>     (propertize
>      "TEST" 'font-lock-face
>      '(:weight bold :background "yellow" :slant italic
> 	     :foreground "red" :underline t)))
> 
> If you use the above, foreground-color-at-point etc. will work as
> expected.
> 
> I'm not sure we want to go out of our way to support the kind of face
> specifications that you used.

However, if we do want that, we already have the technology:

  (face-attributes-as-vector (get-char-property (point) 'font-lock-face))

This will return a vector of face attribute values, where you can find
the value of any attribute you like.  For example, to get the
foreground color, evaluate:

  (aref 9
    (face-attributes-as-vector (get-char-property (point) 'font-lock-face)))