all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Lars Ingebrigtsen <larsi@gnus.org>, Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: RE: Idea: Be able to use text properties as face attributes
Date: Wed, 29 Mar 2017 10:08:03 -0700 (PDT)	[thread overview]
Message-ID: <64c58be2-17e5-478c-ac0e-092adf17b768@default> (raw)
In-Reply-To: <m3mvc4nm72.fsf@stories>

> > IOW, I'm still struggling to understand why you attach this feature to
> > faces, and to faces only.
> 
> I may well be misunderstanding what Drew is asking for, because I didn't
> understand it the first four times he explained it, either.  But I think
> he's asking for something that works like a face, but includes all text
> properties.

Yes.  "Works like a face" is a good way to put it.

It is what I meant by leveraging existing, convenient ways
of applying (and unapplying), and specifying, faces.

Wrt "includes all text properties":

1. At least _tolerates_ all of them, ignoring any that w
decide not to teach Emacs to handle.

2. Includes _within a given face spec_.  The face definition
is used as an object that encapsulates a certain number of
non-face text properties.

Face A might use one value of text property `keymap', and
face B might use another.  In neither case would property
`keymap' be applied directly to the underlying text where
the face is applied.  Only the face property is applied
to the text (for this feature).

This lets you remove or change property `keymap' for all
occurrences of a given face.  And it lets Lisp code
distinguish properties that are attached directly to
the text and are thus not dependent on any face from
properties that are applied indirectly by way of the
face.

> That is:  He wants to say
> (defprop my-prop '(:read-only t :invisible nil :font "futura"))
> (set-text-prop (point-min) (+ (point-min) 4) my-prop)
> (set-text-prop (+ (point-min) 10) (+ (point-min) 20) my-prop)
> and then
> (set-prop my-prop :invisible t)

Nope.  That doesn't use faces at all.  It just attaches the
properties to the text directly.  It in no way lets you
leverage the features we have for applying faces, and it in
no way bundles the properties within a face spec, so that
changing the face changes (in effect) the properties of the
text where the face is applied.

> and then these two ranges would suddenly become invisible.
> So it's like...  a CSS selector...  kinda.
> 
> The thing is, I think you can just cheat and this thing is already
> available?  That is, just make my-prop a list, apply that list to the
> regions you are interested in, and then just mutate that list instead of
> using the property functions?  Or does set-text-properties copy
> PROPERTIES before putting them on the text?  I have neither tested nor
> read the source code.

See above.  Yes, you can already apply text properties
directly to text.  That's not what this feature is about.

And it's not only about being able to change a set of
props that is applied at various locations (though yes,
there is that effect from the proposal).  It's also
about taking advantage of face features, in particular,
convenient ways to apply them.

If you look at the fact that Emacs at one point added
to font-lock the ability to "manage" (to some extent)
other, non-face text properties, this feature is in
a similar vein.

Why did we add that extension to non-face props?
Because font-lock provides a _convenient way to
specify how and where to apply_ a property.

Imagine that!  Yep, font-lock applying a non-face
property is "just a convenience".  And a very
convenient one, too. ;-)  Do most users use it?
Probably not.  That doesn't mean we shouldn't
have added it.



  parent reply	other threads:[~2017-03-29 17:08 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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           ` Idea: Be able to use text properties as face attributes 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 [this message]
     [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
     [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>
2017-03-27 16:22   ` Drew Adams
2017-03-27 18:52     ` Eli Zaretskii
2017-03-26 19:14 Drew Adams
2017-03-26 20:01 ` Clément Pit-Claudel
2017-03-26 21:42   ` Drew Adams
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

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=64c58be2-17e5-478c-ac0e-092adf17b768@default \
    --to=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.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.