From: Drew Adams <drew.adams@oracle.com>
To: Wolfgang Jenkner <wjenkner@inode.at>
Cc: emacs-devel@gnu.org
Subject: RE: feature request: text property to prevent font-locking
Date: Sun, 31 Aug 2014 09:03:48 -0700 (PDT) [thread overview]
Message-ID: <aa407349-5193-42d1-a516-042c628b1acb@default> (raw)
In-Reply-To: <8538cc4sv7.fsf@iznogoud.viz>
> font-lock-default-unfontify-region leaves alone any "alternative"
> (defined in char-property-alias-alist) of the `face' text property.
"Leaves alone?" It think it does the opposite: it removes its
highlighting: it treats the alternative property like it treats
`face' (and `font-lock-face'). But perhaps I misunderstand you.
> In particular, this is how the font-lock-face text property works.
Yes, and thanks for pointing that out, as it is not obvious how
`font-lock-face' is handled by `font-lock-default-unfontify-region'.
But again, IIUC, it does not "leave alone" `font-lock-face'd text.
It does just the opposite: it unfontifies it.
That's even worse wrt unhighlighting than not doing anything.
If you do nothing, then text that you have applied `face' to
will at least appear highlighted when you turn off `font-lock-mode'.
By using your suggested "leave alone" approach, you give font-lock
control over not only highlighting but unhighlighting, so your
ad hoc highlighting will never show, whether font-lock is on or off.
> Now, on the one hand, keyword fontification does not override
> "alternatives" (except if the highlight pattern has an `override'
> flag). This is because text-property-not-all recognizes them and
> thus prevents font-lock-apply-highlight from adding a value for
> the `face' property.
Yes. That is the point, AFAICT, of `font-lock-face': to let you
give font-lock control over some ad hoc highlighting. And yes,
you can use an "alternative" property for the same thing.
> On the other hand, some experimenting suggests that syntactic
> fontification does override those "alternatives".
Yes, I noticed that too.
But beyond that: What you are describing is just the control that
font-lock has over highlighting, and how one can give it control
over additional, non-`font-lock-keywords' highlighting by using
`font-lock-face' (or another property besides `face', designated
as a `face' "alternative").
What I am talking about is the opposite: Not giving font-lock
control over additional, ad hoc highlighting, but taking font-lock
control away, for given ad hoc highlighting. I don't want turning
font-lock on or off to affect the given highlighting at all.
That's the point. It's not that I'm looking for a way to let
font-lock control some non-`font-lock-keywords' highlighting.
That we can do already, using property `font-lock-face'.
(And my guess is that the fact that this is the only feature for
ad hoc highlighting that is compatible with font-lock is a reason
that we have seen an expansion of the use of `font-lock-face'.
IOW, if you want some ad hoc highlighting, you are currently
pretty much obliged to give font-lock control over it, by using
that approach.)
> > I want to apply some other text property to the highlighted text,
> > to tell font-lock not to fiddle with it ("hands off this text").
>
> Remove it from the value of `font-lock-extra-managed-props'.
Remove what? The highlighting property? It's `face', which is
already not in `font-lock-extra-managed-props'. The default value
of `font-lock-extra-managed-props' is nil (or it should be; and
hopefully it will be again, after bug #18343 gets fixed).
That's the point: font-lock should not "own" `face'. And it
pretty much does currently. Whether it did in the beginning I
don't know, but I kinda doubt it. Property `face' was not
invented for font-lock, AFAIK. Font-lock is one application of
the feature of faces; nothing more. But it does not play well
with other uses of that feature - it is a sandbox bully.
> tl; dr: Existing facilities reduce the problem to clashes with
> syntactic fontification.
That's your point, not mine. But yes, the feature I proposed
lets you protect given text also from overriding by syntactic
fontification.
prev parent reply other threads:[~2014-08-31 16:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-28 21:18 feature request: text property to prevent font-locking Drew Adams
2014-08-30 9:27 ` Alan Mackenzie
2014-08-30 20:15 ` Drew Adams
2014-08-30 21:34 ` Thien-Thi Nguyen
2014-08-31 6:06 ` Drew Adams
2014-08-31 16:11 ` Drew Adams
2014-08-31 12:40 ` Stefan Monnier
2014-08-31 15:30 ` Drew Adams
2014-08-31 19:57 ` Stefan Monnier
2014-08-31 21:07 ` Drew Adams
2014-08-31 21:43 ` Alan Mackenzie
2014-09-01 1:37 ` Stephen J. Turnbull
2014-09-01 20:45 ` Stefan Monnier
2014-09-02 2:02 ` Stephen J. Turnbull
2014-09-02 2:33 ` Richard Stallman
2014-09-02 6:04 ` David Kastrup
2014-08-31 14:31 ` Wolfgang Jenkner
2014-08-31 16:03 ` Drew Adams [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aa407349-5193-42d1-a516-042c628b1acb@default \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=wjenkner@inode.at \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).