all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: "Clément Pit-Claudel" <cpitclaudel@gmail.com>, emacs-devel@gnu.org
Subject: RE: Idea: Be able to use text properties as face attributes
Date: Sun, 26 Mar 2017 14:42:58 -0700 (PDT)	[thread overview]
Message-ID: <2c5fce4c-c79a-41f7-9162-e99148665be5@default> (raw)
In-Reply-To: <8800c317-f4c1-d1b2-a9cf-c871d6190c53@gmail.com>

> > 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
face-related.

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	other threads:[~2017-03-26 21:42 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-26 19:14 Idea: Be able to use text properties as face attributes Drew Adams
2017-03-26 20:01 ` Clément Pit-Claudel
2017-03-26 21:42   ` Drew Adams [this message]
2017-03-26 22:14     ` Clément Pit-Claudel
2017-03-26 23:26       ` Drew Adams
2017-03-27  1:23         ` Clément Pit-Claudel
2017-03-27 14:54   ` Eli Zaretskii
2017-03-27  4:51 ` Drew Adams
2017-03-27 14:01   ` Drew Adams
2017-03-27 14:57     ` Eli Zaretskii
     [not found]   ` <<30eb5a49-2d98-4f37-8f8c-32a88cd76827@default>
     [not found]     ` <<83bmsm938f.fsf@gnu.org>
2017-03-27 15:49       ` Drew Adams
2017-03-27 18:59         ` Eli Zaretskii
     [not found]   ` <<<30eb5a49-2d98-4f37-8f8c-32a88cd76827@default>
     [not found]     ` <<<83bmsm938f.fsf@gnu.org>
     [not found]       ` <<7f98847c-9b5e-47cf-85f2-247c2045d0af@default>
     [not found]         ` <<834lye8s1k.fsf@gnu.org>
2017-03-27 20:01           ` Drew Adams
2017-03-28 15:06             ` Eli Zaretskii
2017-03-28 15:26               ` Stefan Monnier
2017-03-28 21:40                 ` Drew Adams
2017-03-28 22:45                   ` Stefan Monnier
2017-03-28 23:10                     ` Drew Adams
2017-03-29  1:36                       ` Stefan Monnier
2017-03-29  5:32                         ` Drew Adams
     [not found]   ` <<<<30eb5a49-2d98-4f37-8f8c-32a88cd76827@default>
     [not found]     ` <<<<83bmsm938f.fsf@gnu.org>
     [not found]       ` <<<7f98847c-9b5e-47cf-85f2-247c2045d0af@default>
     [not found]         ` <<<834lye8s1k.fsf@gnu.org>
     [not found]           ` <<93aa220a-35c8-4be1-bfb5-299c46c9eba9@default>
     [not found]             ` <<83tw6d785i.fsf@gnu.org>
2017-03-28 21:39               ` Drew Adams
2017-03-27  7:56 ` Yuri Khan
2017-03-27 14:01   ` Drew Adams
2017-03-27 14:55   ` Eli Zaretskii
2017-03-27 14:51 ` Eli Zaretskii
     [not found] <<7a902f7b-d808-4d0f-8ff9-b8f07eaddf83@default>
     [not found] ` <<83h92e93ip.fsf@gnu.org>
2017-03-27 16:22   ` Drew Adams
2017-03-27 18:52     ` Eli Zaretskii
     [not found] <<<7a902f7b-d808-4d0f-8ff9-b8f07eaddf83@default>
     [not found] ` <<<83h92e93ip.fsf@gnu.org>
     [not found]   ` <<8080a162-700f-42cc-aec9-5fdd7c646297@default>
     [not found]     ` <<8360iu8sdm.fsf@gnu.org>
2017-03-27 20:01       ` Drew Adams
2017-03-28 15:08         ` Eli Zaretskii
     [not found] <<<<7a902f7b-d808-4d0f-8ff9-b8f07eaddf83@default>
     [not found] ` <<<<83h92e93ip.fsf@gnu.org>
     [not found]   ` <<<8080a162-700f-42cc-aec9-5fdd7c646297@default>
     [not found]     ` <<<8360iu8sdm.fsf@gnu.org>
     [not found]       ` <<19e94d18-656f-4a8f-8843-4d46ffdd037b@default>
     [not found]         ` <<83shlx782i.fsf@gnu.org>
2017-03-28 21:39           ` Drew Adams
2017-03-29 14:51             ` Eli Zaretskii
2017-03-29 15:21               ` Lars Ingebrigtsen
2017-03-29 15:36                 ` Clément Pit-Claudel
2017-03-29 17:08                   ` Drew Adams
2017-03-29 15:41                 ` Andreas Politz
2017-03-29 17:08                 ` Drew Adams
     [not found] <<<<<7a902f7b-d808-4d0f-8ff9-b8f07eaddf83@default>
     [not found] ` <<<<<83h92e93ip.fsf@gnu.org>
     [not found]   ` <<<<8080a162-700f-42cc-aec9-5fdd7c646297@default>
     [not found]     ` <<<<8360iu8sdm.fsf@gnu.org>
     [not found]       ` <<<19e94d18-656f-4a8f-8843-4d46ffdd037b@default>
     [not found]         ` <<<83shlx782i.fsf@gnu.org>
     [not found]           ` <<403a3ff2-464f-4eb5-9843-60592e786955@default>
     [not found]             ` <<83a8846srr.fsf@gnu.org>
2017-03-29 17:06               ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2c5fce4c-c79a-41f7-9162-e99148665be5@default \
    --to=drew.adams@oracle.com \
    --cc=cpitclaudel@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.