GNU bug report logs -
#15900
24.3.50; foreground-color-at-point returns wrong results
Previous Next
Full log
View this message in rfc822 format
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> Hello,
>
> `foreground-color-at-point' doesn't return the expected result when
> there are several faces at point present.
>
> For example, on the red subject in a Gnus article buffer, or on a blue
> link in w3m, it returns "black". Looking at the code, I see that
> `foreground-color-at-point' uses
>
> (face-at-point)
>
> i.e., it looks only at one face and disregards the others. This is
> especially meaningless when this first face doesn't specify any
> foreground at all.
Even
(face-at-point nil 'multiple)
is not correct. Evaluated in w3m with point on a link, i get
==> (w3m-current-anchor)
This is what I get for M-1 C-x = (excerpt)
,----------------------------------------------------------------------
| There is an overlay here:
| From 7785 to 7798
| evaporate t
| face w3m-current-anchor
| w3m-momentary-overlay t
|
|
| There are text properties here:
| balloon-help nil
| face (w3m-anchor)
| help-echo [Show]
| keymap [Show]
| mouse-face highlight
| rear-nonsticky t
| w3m-anchor-sequence 75
| w3m-anchor-title nil
| w3m-balloon-help [Show]
| w3m-href-anchor [Show]
| w3m-name-anchor [Show]
| w3m-name-anchor2 ("showmodes" "gb_70")
| w3m-safe-url-regexp nil
`----------------------------------------------------------------------
`face-at-point' disregards the face text property, it only returns the
face overlay property.
> So, what I need is a reliable `foreground-color-at-point'. Tips and
> alternatives welcome.
I try to use something like this as a workaround now:
--8<---------------cut here---------------start------------->8---
(cl-some
(lambda (face) (not (memq (face-foreground face nil t)
`(nil ,(face-attribute 'default :foreground)))))
(cl-mapcan (lambda (face-or-list) (if (facep face-or-list)
(list face-or-list)
face-or-list))
(list
(get-text-property (point) 'face)
(get-text-property (point) 'font-lock-face))))
--8<---------------cut here---------------end--------------->8---
Regards,
Michael.
This bug report was last modified 3 years and 27 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.