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: Eli Zaretskii
Subject: bug#15900: 24.3.50; foreground-color-at-point returns wrong results
Date: Sat, 16 Nov 2013 10:44:36 +0200

> From: Michael Heerdegen <address@hidden>
> Cc: address@hidden, Drew Adams <address@hidden>
> Date: Fri, 15 Nov 2013 23:18:11 +0100
> 
> > As you later discovered, even (face-at-point nil t) doesn't do the
> > job.
> >
> > Which doesn't surprise me a bit: this kind of things cannot be done
> > reliably from Lisp, even at a price of the kind of obfuscated code
> > that face-at-point and foreground-color-at-point use.  It is much
> > simpler to write a C primitive that simulates the display, then
> > returns the resulting face at a given character position, a simple and
> > straightforward task on the C level, something the display engine does
> > all the time.
> 
> That sounds good.  Can we just do that?

For some value of "we", yes.  If "we" includes me and you, then it
will have to be you, as my plate is pretty much full these days,
sorry.  In my defense, I can tell that this should be a nice exercise
for someone who wants to get accustomed to hacking the display engine,
as it shouldn't be too hard, and there's abundant example code that
does similar things.

> > > P.S. Some background: I'm working on an addition to stripe-buffer.el
> > > that changes the foreground color continuously, instead of changing the
> > > background.  This is for better readability.
> > > 
> > > I want to keep the foreground colors already present, so that e.g. links
> > > in w3m are still recognizable.  Paragraphs in italic can be colored
> > > OTOH.
> > > 
> > > So, what I need is a reliable `foreground-color-at-point'.  Tips and
> > > alternatives welcome.
> >
> > Why can't you detect that a portion of text is covered by specific
> > properties (e.g., one of a list of known properties), and leave those
> > portions alone?
> 
> What do you mean with "properties" - text and overlay properties?

Yes.

> If faces are among them, I still must figure out if one of these
> faces changes the foreground.

You can know them in advance, I think.  Your example talks about
links, which use a known face.  I presume there are only a few faces
that needs such a special treatment, which would make the list of them
quite short.

IOW, why not test against a known list of properties that you want to
leave alone, instead of digging into their color?

> If not, i.e., if a face e.g. just underlines, I do want to color the
> text nevertheless.

The face used by links is different not only in its underline, but
also in its color.  If you want links to remain instantly
recognizable, you should probably keep their appearance intact
wholesale, not just the underline, otherwise how would the user
distinguish between a link and underlined text?

> Probably I didn't understand what you meant.

More probable that I didn't understand what you meant.  Hopefully the
above tells enough about my misunderstanding to allow you to correct
me.





reply via email to

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