help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: font lock woes


From: Joost Kremers
Subject: Re: font lock woes
Date: 4 Mar 2013 18:54:39 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

Stefan Monnier wrote:
>> This suggests to me that I should be able to do:
>> ,----
>> | (font-lock-add-keywords nil `((,(regexp-quote "{++") . '(face 
>> cm-addition-face read-only t))) t)
>> `----
>> but for some reason, the only thing that works is:
>> ,----
>> | (font-lock-add-keywords nil `((,(regexp-quote "{++") 0 '(face 
>> cm-addition-face read-only t))
>> `----
>
> In which way does the other one not work?  Did you check the resulting
> font-lock-keywords?

Yes, I have, and the matchers are there, but the relevant strings do not
get fontified: cm-addition-face (which is just a foreground color) isn't
applied and matching text is not read-only.

>> A second thing I don't understand is how to remove the read-only
>> property again when the mode is deactivated.  I was thinking I should be
>> able to do the following:
>
>> ,----
>> | (font-lock-remove-keywords nil `((,(regexp-quote "{++") 0 '(face 
>> cm-addition-face read-only t))))
>> | (let ((inhibit-read-only t))
>> |   (font-lock-fontify-buffer))
>> | (setq font-lock-extra-managed-props (delq 'read-only 
>> font-lock-extra-managed-props))
>> `----
>
> font-lock-fontify-buffer just schedules a refontification, which will be
> done later, on-the-fly, piece by piece as text is displayed.

But then why do the colors get removed? I mean, after disabling the mode
with the code above, the font lock colors that my mode adds are removed,
just the read-only property stays.

I see now that that's only in the visible part of the buffer, so either
way it's not going to work the way I'd like, but still, even in the
visible part of the buffer, the call to font-lock-fontify-buffer above
removes the font-lock-face property but not the read-only property.
Which suggests that the properties in font-lock-extra-managed-props are
handled differently from font-lock-face...

> Much simpler is to remove-text-properties by hand.

Yeah, look like...

Thanks for your answer. I'll have to give some thought to how best do do
what I'm after.


-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]