From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: font lock woes Date: 4 Mar 2013 18:54:39 GMT Message-ID: References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1362425672 8076 80.91.229.3 (4 Mar 2013 19:34:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Mar 2013 19:34:32 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 04 20:34:56 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UCbA0-0006Of-8V for geh-help-gnu-emacs@m.gmane.org; Mon, 04 Mar 2013 20:34:56 +0100 Original-Received: from localhost ([::1]:60018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCb9e-0003Bc-PC for geh-help-gnu-emacs@m.gmane.org; Mon, 04 Mar 2013 14:34:34 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 54 Original-X-Trace: individual.net 63mAlSnFb8oGafzfejVoug0Ru6yKAGcuTILv2qDzLJtIFbgXhi3DpCf1TlDW6Kd9Cs Cancel-Lock: sha1:+vbDkGVTkDbYQVwfJmu2hP5WuqQ= Mail-Copies-To: nobody X-Editor: Emacs of course! User-Agent: slrn/pre1.0.0-18 (Linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:197063 X-Mailman-Approved-At: Mon, 04 Mar 2013 14:34:11 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:89345 Archived-At: 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)