[Top][All Lists]

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

RE: Idea: Be able to use text properties as face attributes

From: Drew Adams
Subject: RE: Idea: Be able to use text properties as face attributes
Date: Sun, 26 Mar 2017 14:42:58 -0700 (PDT)

> > WDOT?  Is this something that would be useful?  If so, would
> > someone like to work on implementing it?
> This sounds interesting, and the proposal is clear and nice.  Can you
> think of concrete examples where it would things much easier for
> package developers (your example with 'invisible is nice)?

I haven't thought much about uses, in particular for packages.
I expect that others can come up with more possible uses.

The main point, for me, is that it provides a way to change
the properties of many stretches of text all at once, namely
all text (or all text on a given frame) that has a given face.

> I can think of one, if I understand correctly.  Currently, if one want font-
> lock to apply properties other tan face, then one must add these properties
> to font-lock-extra-managed-props — and then font-lock will remove these
> properties indiscriminately, regardless of where they came from.  This makes
> things difficult sometimes. With your proposal, these attributes could be
> tucked in a face.

Yes, that's what I meant by saying that you can turn all uses
of a given face from `face' uses to `font-lock-face' uses, i.e.,
hand its control over to font-lock.

I like your expression "these attributes could be tucked in[to]
a face".  Which means that manipulating/using the face means
also (indirectly) manipulating/using the other properties that
the face carries on board.  Wherever the face is used, so are
the other properties used.

And it means nothing beyond that.  In particular, as you say,
only the uses of that one face are affected.

And to be clear, it's not about this feature _instead of_ some
other approach.  In particular, when it suits, which is probably
most of the time, changing properties directly is fine.  You
don't _have_ to couple a face with properties that are not

The point is only that you _can_ do that, so you can take
advantage of bulk-applying (or bulk-removing) such non-face
properties from a bunch of locations, all at once.  The face
that holds them acts as a _carrier_ for them.

> I wonder if your suggestion could be generalized.  Fundamentally,
> is there a good reason to have a distinction between face
> properties and text properties ?

Well, the suggestion is to let most (all?) text properties
_be_ face properties, in the sense that a face can hold them.
(That doesn't mean that they all need to have an effect on
the text that is related to the effect of the face on it.)

Clearly there is a distinction between text properties that
are related to faces and those that are not, where the latter
are (also or instead) related to things other than the
appearance of a face.

And let's not forget that anyone can create any text property
(e.g. `jkjkljkl'), with any value, and apply it to some text.

Some text properties that are not really related to faces
are built-in (`emacs -Q').  Others are created by user code
that alone determines how they behave - what their effect is.

But I guess you are suggesting the other direction: that
all face attributes would be applicable to text as text
properties on their own.  E.g., you would be able to do:

 (put-text-property 30 42 :family "Palatino")

That might be another possible enhancement.  But I think
that is already possible using an anonymous face (see
(elisp) `Special Properties'):

 (put-text-property 30 42 'face '(:family "Palatino"))

Is there something else you were thinking of here?

> Then faces would work in a similar fashion to overlay
> categories (a quick way to set consistent properties on
> many chunks of text)

Maybe you could elaborate, e.g., with a (fictitious) example?
Maybe show what else you think is needed for that, beyond
what I suggested.

(BTW, I just noticed that the text property `category' and
the overlay property `category' are apparently completely
different beasts.  Why did we choose to use the same name
for them?  Seems like the text property should instead be
called `char-category' or some such.)

reply via email to

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