[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to prevent font-lock from messing with a portion of text?
From: |
Stefan Monnier |
Subject: |
Re: how to prevent font-lock from messing with a portion of text? |
Date: |
Mon, 26 Mar 2007 09:01:04 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux) |
> (defun put-text-property-unless-ignore (start end property value &optional
> object)
> "`put-text-property', but ignore text with property `font-lock-ignore'."
> (let ((here (min start end))
> (end1 (max start end)))
> (while (< here end1)
> (unless (get-text-property here 'font-lock-ignore object)
> (put-text-property here (1+ here) property value object))
> (setq here (1+ here)))))
This will still override a face on a word inside a string, because
(get-text-property <string-start> 'font-lock-ignore object) will be nil.
You need to check for the presence of the property over the whole
start..end region.
> 2. In font-lock.el, use this definition of
> `font-lock-default-unfontify-region':
> (defun font-lock-default-unfontify-region (beg end)
> "Unfontify from BEG to END, unless text with property `font-lock-ignore'."
> (let ((here (min beg end))
> (end1 (max beg end)))
> (while (< here end1)
> (unless (get-text-property here 'font-lock-ignore)
> (remove-list-of-text-properties
> here (1+ here) (append font-lock-extra-managed-props
> (if font-lock-syntactic-keywords
> '(syntax-table face font-lock-multiline)
> '(face font-lock-multiline)))))
> (setq here (1+ here)))))
Same thing here, except even more so.
Then the problem becomes that doing all those extra checks costs time, all
the time, for a feature which will be almost never used.
OK, here's another option: don't change anything to font-lock, don't fiddle
with it at all, just don't use text-properties to add your special faces.
Use overlays instead.
Problem solved,
Stefan
- Re: how to prevent font-lock from messing with a portion of text?, (continued)
- Re: how to prevent font-lock from messing with a portion of text?, Stefan Monnier, 2007/03/24
- RE: how to prevent font-lock from messing with a portion of text?, Drew Adams, 2007/03/25
- Re: how to prevent font-lock from messing with a portion of text?, Lennart Borgman (gmail), 2007/03/25
- RE: how to prevent font-lock from messing with a portion of text?, Drew Adams, 2007/03/26
- Re: how to prevent font-lock from messing with a portion of text?, Lennart Borgman (gmail), 2007/03/26
- RE: how to prevent font-lock from messing with a portion of text?, Drew Adams, 2007/03/26
- Re: how to prevent font-lock from messing with a portion of text?,
Stefan Monnier <=
- Re: how to prevent font-lock from messing with a portion of text?, Miles Bader, 2007/03/26
- RE: how to prevent font-lock from messing with a portion of text?, Drew Adams, 2007/03/26
- RE: how to prevent font-lock from messing with a portion of text?, Drew Adams, 2007/03/26
- Re: how to prevent font-lock from messing with a portion of text?, Stefan Monnier, 2007/03/26
- RE: how to prevent font-lock from messing with a portion of text?, Drew Adams, 2007/03/26