all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Alan Mackenzie <acm@muc.de>
Cc: emacs-devel@gnu.org
Subject: RE: feature request: text property to prevent font-locking
Date: Sat, 30 Aug 2014 13:15:46 -0700 (PDT)	[thread overview]
Message-ID: <34f3e246-bbfb-4864-83e9-4a0c81d4202e@default> (raw)
In-Reply-To: <20140830092701.GA3351@acm.acm>

> For this particular application of fontifying, you might be able to
> use overlays, which take priority over text properties (see page
> "Overlay Properties" in the Elisp manual).  You might have to define
> a lot of attributes for the overlay face to prevent attributes from
> font-locking "showing through".
> 
> That feels like a bit of a kludge, though.  The facility you've
> sketched out (and implemented) might well be a useful one.

Just in case I was not clear enough -

I do use overlays, when they are appropriate.  They are essentially
about buffer positions, not the text in the buffer.  But yes, one
can fiddle with overlays to work around the effective removal, in a
font-locked buffer, of the possibility of using `face' as a text
property for other than font-locking.  Like others, I have done that.

I suspect that people have gotten used to this behavior by font-lock
and act as if it were normal.

But font-lock does not (should not) own text-property `face', even
in font-locked buffers.  You should not need to resort to using
`face' with overlays, just to get around font-lock's effective
confiscation of it for buffer text.  You should be able to apply
`face' to any buffer text and have a way to prevent it being taken
over by font-lock there.

And yes, people sometimes try other ways to work around the
expropriation of `face' by font-lock.  They try to show links on
top of font-locked text by using property `display', for example.

And yes, people sometimes end up using font-lock itself to add
ad-hoc highlighting, not because it is particularly appropriate for
the particular use case, but because there is little choice to do
otherwise.

AFAICT, this is just a missing Emacs feature: be able to exclude
zones of text from being taken over by font-lock.  Stop font-lock
from changing property `face' from a value set by non font-lock
highlighting.

This feature is essentially what font-lock itself already provides for
given font-lock rules (keywords), via keyword `keep'.  The problem is
that Font-lock does not recognize any such protection outside
`font-lock-keywords'.

So again, I am not looking to solve a particular highlighting problem
by a workaround (overlays, other text properties such as `display',...).

I'm arguing that there should be a simple way to tell font-lock "Hands
off!" particular text.  It should be simple to indicate that property
`face' on this or that text is not open to being altered by font-lock.

And I do have a solution - a trivial patch, as I indicated.  And for
users a simple way to tell font-lock "Hands off!": just put text
property `font-lock-ignore' where you do not want font-lock to change
text properties.  I cannot see a downside to providing this.

But since your reply is the only one so far, Alan, I conclude so far
that there is no special interest in this -the problem or the
proposed solution.  That's OK by me - I'll continue to use the code
I have.  And others can continue to add a `display' property or
whatever to get around the roughshod behavior of font-lock.  Been
there, done that.

And just in case, I'll send the patch, with `report-emacs-bug'.

As I said:
 I use this feature for various highlighting (and unhighlighting)
 commands, so that the highlighting works for font-locked text too.
 This includes `facemenu-add-face' (my version).

I use it for links (`link' face), `facemenu-add-face' (any face),
`hlt-highlighter' & `hlt-eraser' (mouse-drag highlighter/eraser),
`hlt-region' (arbitrary (un)highlighting), `hlt-yank-props' (paste
copied text properties), and more.



  reply	other threads:[~2014-08-30 20:15 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 [this message]
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

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=34f3e246-bbfb-4864-83e9-4a0c81d4202e@default \
    --to=drew.adams@oracle.com \
    --cc=acm@muc.de \
    --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.