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: font lock woes Date: 3 Mar 2013 23:22:00 GMT Message-ID: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1362380731 22314 80.91.229.3 (4 Mar 2013 07:05:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Mar 2013 07:05:31 +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 08:05:55 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 1UCPT4-0001jl-EQ for geh-help-gnu-emacs@m.gmane.org; Mon, 04 Mar 2013 08:05:50 +0100 Original-Received: from localhost ([::1]:39556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCPSj-00015H-1U for geh-help-gnu-emacs@m.gmane.org; Mon, 04 Mar 2013 02:05:29 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 72 Original-X-Trace: individual.net X7usSNcUPAvQmVGLpnv5IA4vPYByaZSkbX4uMxbaha0Wakh3qMLbtJAy2R8B+XjM9g Cancel-Lock: sha1:gqT2PwrwmRymIu3JfBntBrkM8k4= User-Agent: slrn/pre1.0.0-18 (Linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:197055 X-Mailman-Approved-At: Mon, 04 Mar 2013 02:04:47 -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:89335 Archived-At: EN:SiS(9) Hi all, I'm writing a minor mode that (among other things) adds some font lock patterns to the buffer's font-lock-keywords, using font-lock-add-keywords, but I'm running into some problems. First, one of the things I'm trying to do is to add some additional text properties beside a face spec. (info "(elisp) Search-based Fontification") has the following to say on this: ,---- | `(MATCHER . FACESPEC)' | [...] | However, FACESPEC can also evaluate to a list of this form: | | (face FACE PROP1 VAL1 PROP2 VAL2...) | | to specify the face FACE and various additional text properties to | put on the text that matches. If you do this, be sure to add the | other text property names that you set in this way to the value of | `font-lock-extra-managed-props' so that the properties will also | be cleared out when they are no longer appropriate. `---- 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)) `---- Am I misunderstanding the info node, or is Info wrong? (I'm running GNU Emacs 24.3.50.1, BTW). 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)) `---- I figured if I remove the relevant matcher from font-lock-keywords, then refontify the buffer and only then remove the read-only property from font-lock-extra-managed-props, things should work. But they don't: the text that was made read-only with font-lock remains read-only. Only if I don't remove 'read-only from font-lock-extra-managed-props at all, does it work: in that case, the read-only property is removed. But I don't like the idea that font-lock-extra-managed-props isn't restored to its original value. So I'm wondering if there's a better way of doing this. It's the first time I'm trying to do anything with font-lock. I'd appreciate any and all comments! TIA -- Joost Kremers joostkremers@fastmail.fm Selbst in die Unterwelt dringt durch Spalten Licht