|
From: | Lennart Borgman (gmail) |
Subject: | Re: how to prevent font-lock from messing with a portion of text? |
Date: | Fri, 23 Mar 2007 18:31:09 +0100 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.5.666 |
Drew Adams wrote:
Wrt Lennart's suggestion, BTW: I want to be able to also remove the highlighting and then have font-lock treat that text normally again. So, nothing that permanently prevents font-lock from fontifying the text would be useful here.
I understand that my suggestion does not fit your needs now, but it is quite easy to let font-lock take over the fontifying again.
As a simple example, imagine that you want to be able to use `M-o o' (facemenu-set-face) on some text in a font-locked buffer. Currently, `M-o o' just tells you that "Font-lock mode will override any faces you set in this buffer" - IOW, you're SOL. If you want to see your highlighting, you must turn off font-lock. Instead of punting this way, `M-o o' could do what's needed to prevent font-lock from interfering - that is, from changing the facemenu highlighting.
To do that kind of thing you want you have to change font-lock-fontify-region function. However that will not work for all modes, only those that uses this. So at the moment you really can not do it.
To temporary set a face like you want to do I think you need to use overlays.
BTW, the doc does not explain anywhere (that I've found) just how the activation of `font-lock-face' is controlled by `font-lock-mode'. It says only that the mode toggles the activation of the property.
It seems to me that there are indeed things missing in the manual.
[Prev in Thread] | Current Thread | [Next in Thread] |