bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15900: 24.3.50; foreground-color-at-point returns wrong results


From: Michael Heerdegen
Subject: bug#15900: 24.3.50; foreground-color-at-point returns wrong results
Date: Fri, 15 Nov 2013 03:47:41 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Michael Heerdegen <address@hidden> 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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]