[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#65632: 30.0.50; Proposal to improve `faces--attribute-at-point'.
From: |
David Ponce |
Subject: |
bug#65632: 30.0.50; Proposal to improve `faces--attribute-at-point'. |
Date: |
Wed, 30 Aug 2023 20:04:49 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 |
Hello,
I noticed that the functions `foreground-color-at-point' and
`background-color-at-point' don't return expected values when the face
at point includes anonymous face or is a nested list of face, for
example.
Here is a simple recipe that demonstrates the issue (emacs -Q):
In scratch buffer eval:
-----------------------
;; Display "TEST" in red, bold, italic on yellow background.
(insert
(propertize
"TEST" 'font-lock-face
'(bold ((:background "yellow") "italic"
((foreground-color . "red") underline)))))
TESTnil
;; Then click to move point somewhere on TEST and run
M-: (foreground-color-at-point) RET
result is "black" instead of "red"
M-: (background-color-at-point) RET
result is "white" instead of "yellow"
I propose the attached patch to faces.el to improve things.
The patch introduce a new function `face-attribute-lookup' to lookup
face attribute, that works when face specification is complex like in
above example. The function `faces--attribute-at-point' is simplified
to use it.
Here is a possible changelog:
* faces.el: Improve attribute lookup of face at point.
(face--unnamed-attributes): New constant.
(face--attribute-unspecified-p)
(face-attribute-lookup): New functions.
(faces--attribute-at-point): Use it. Remove useless argument.
(foreground-color-at-point)
(background-color-at-point): Update accordingly.
Thanks
faces-attribute-lookup-V0.patch
Description: Text Data
- bug#65632: 30.0.50; Proposal to improve `faces--attribute-at-point'.,
David Ponce <=