From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: how to prevent font-lock from messing with a portion of text? Date: Fri, 23 Mar 2007 18:36:14 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1174695738 20169 80.91.229.12 (24 Mar 2007 00:22:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 24 Mar 2007 00:22:18 +0000 (UTC) Cc: Emacs-Devel To: "Drew Adams" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 24 01:22:10 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HUu1J-0002oB-9J for ged-emacs-devel@m.gmane.org; Sat, 24 Mar 2007 01:22:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HUu3G-0003tm-Db for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2007 19:24:10 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HUu3C-0003rP-NE for emacs-devel@gnu.org; Fri, 23 Mar 2007 20:24:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HUu3B-0003qP-JK for emacs-devel@gnu.org; Fri, 23 Mar 2007 20:24:06 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HUu3B-0003ps-Fz for emacs-devel@gnu.org; Fri, 23 Mar 2007 19:24:05 -0500 Original-Received: from bc.sympatico.ca ([209.226.175.184] helo=tomts22-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HUu1D-0004GU-HV for emacs-devel@gnu.org; Fri, 23 Mar 2007 20:22:03 -0400 Original-Received: from ceviche.home ([70.55.83.113]) by tomts22-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070324002201.SWE1767.tomts22-srv.bellnexxia.net@ceviche.home> for ; Fri, 23 Mar 2007 20:22:01 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 5B762B5001; Fri, 23 Mar 2007 18:36:14 -0400 (EDT) In-Reply-To: (Drew Adams's message of "Fri\, 23 Mar 2007 10\:13\:06 -0700") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.96 (gnu/linux) X-detected-kernel: Solaris 8 (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:68445 Archived-At: >> > Use put-text-property to add a face to some text using the >> > `face' property. >> > Prevent subsequent "erasure" of that highlighting by font-lock. >> >> The `font-lock-face' property was designed specifically for this >> kind of case. > 1. That's only for Emacs 22. Yup. > 2. It doesn't prevent font-lock from clobbering the highlighted text when > doing syntactic font lock (e.g. in comments). It's true that font-lock's own faces take precedence. But the font-lock-face property is not clobbered. > 3. The highlighting is removed when font-lock-mode is turned off. Again, the lont-lock-face properties are not removed. But yes, it is made inactive. > 4. It won't help with other code (e.g. 3rd library) that happens to use the > `face' property. Yup. > IOW, no, `font-lock-face' property was not at all designed specifically for > this > kind of case. Highlight some text, and have it stay highlighted whether or > not font-lock-mode is on. Have font-lock ignore that text when it does its > own highlighting. Well, with those extra conditions, then indeed, no it doesn't quite fit your bill. How 'bout: - use font-lock-mode-hook to move `face' properties to/from a new property `persistent-face' when turning font-lock-mode on/off. - add a font-lock-fontify-region-function so that after fontifying the region normally, you scan the region for `persistent-face' properties and copy those to the `face' property. > That's too bad. How about adding that, after the release? I'm not interested in coding it up because I don't see a need for it, but if someone provides a clean patch, I don't see any reason why I'd oppose it. > From what you say, it sounds as if that whole passage about that property > should be stated in terms of jit-lock only. And there should be a cross > reference to the place where jit-lock is introduced. Yes, that's probably right. Stefan