From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: font lock woes Date: Mon, 04 Mar 2013 17:32:27 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1362436384 15747 80.91.229.3 (4 Mar 2013 22:33:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Mar 2013 22:33:04 +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 23:33:28 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 1UCdwc-0004GL-T1 for geh-help-gnu-emacs@m.gmane.org; Mon, 04 Mar 2013 23:33:19 +0100 Original-Received: from localhost ([::1]:49653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCdwH-0006Q8-Ec for geh-help-gnu-emacs@m.gmane.org; Mon, 04 Mar 2013 17:32:57 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCdw7-0006Mu-OT for help-gnu-emacs@gnu.org; Mon, 04 Mar 2013 17:32:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCdw6-0003Vs-Jg for help-gnu-emacs@gnu.org; Mon, 04 Mar 2013 17:32:47 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:50130) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCdw6-0003Vo-DL for help-gnu-emacs@gnu.org; Mon, 04 Mar 2013 17:32:46 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UCdwO-00040k-1T for help-gnu-emacs@gnu.org; Mon, 04 Mar 2013 23:33:04 +0100 Original-Received: from 69-196-187-203.dsl.teksavvy.com ([69.196.187.203]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Mar 2013 23:33:04 +0100 Original-Received: from monnier by 69-196-187-203.dsl.teksavvy.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Mar 2013 23:33:04 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 50 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 69-196-187-203.dsl.teksavvy.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:i16n0i3oY80r4Tt+wYlJkhMB694= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:89350 Archived-At: >>> 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. Could it be that the relevant strings already have some other face? If so, you'll want to use an OVERRIDE flag (see C-h v font-lock-keywords). >>> 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. Because you've removed `read-only' from font-lock-extra-managed-props, so read-only is not removed any more. > 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. No, the call itself does not, it only schedules the buffer for refontification, i.e. the font-lock-face is only removed (in the visible part) during the next redisplay, at which point you've already removed `read-only' from font-lock-extra-managed-props. Stefan