From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: How to prevent font-lock (& jit-lock etc.) from refontifying? Date: Wed, 13 Oct 2004 15:07:35 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1097705359 19714 80.91.229.6 (13 Oct 2004 22:09:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 13 Oct 2004 22:09:19 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 14 00:09:07 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CHrIx-0008B3-00 for ; Thu, 14 Oct 2004 00:09:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CHrQ0-0000HD-EP for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Oct 2004 18:16:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CHrPl-0000Dx-Cn for help-gnu-emacs@gnu.org; Wed, 13 Oct 2004 18:16:09 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CHrPk-0000DS-5I for help-gnu-emacs@gnu.org; Wed, 13 Oct 2004 18:16:08 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CHrPh-0000CN-Md for help-gnu-emacs@gnu.org; Wed, 13 Oct 2004 18:16:07 -0400 Original-Received: from [141.146.126.231] (helo=agminet04.oracle.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CHrHh-0007Tq-W9 for help-gnu-emacs@gnu.org; Wed, 13 Oct 2004 18:07:50 -0400 Original-Received: from rgmgw1.us.oracle.com (rgmgw1.us.oracle.com [138.1.191.10]) by agminet04.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i9DM7cVK007942; Wed, 13 Oct 2004 15:07:40 -0700 Original-Received: from rgmgw1.us.oracle.com (localhost [127.0.0.1]) by rgmgw1.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i9DM7b7i026600; Wed, 13 Oct 2004 16:07:37 -0600 Original-Received: from dradamslap (dradams-lap.us.oracle.com [130.35.177.126]) by rgmgw1.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with SMTP id i9DM7bGi026559; Wed, 13 Oct 2004 16:07:37 -0600 Original-To: "Stefan Monnier" , X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Importance: Normal X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 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 Xref: main.gmane.org gmane.emacs.help:21240 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21240 I guess that's as close as I'll get to what I was looking for. In this case, I can use inhibit-modification-hooks, but in general that does more than just tell font-lock not to refontify; it inhibits all *-change-functions. I just wanted to be able to write some code that highlights things regardless of the buffer mode and regardless of whether font-lock-mode is on. Yes, the highlighting could be temporary until a buffer change. Besides using inhibit-modification-hooks, it looks like there is now no way to tell font-lock not to refontify. IOW, "you can't get there from here". Either: - the user happens to be using font-lock, in which case you could either add the highlighting regexps to font-lock-keywords or use font-lock-face - or the user doesn't happen to be using font-lock, in which case your code cannot depend on font-lock to do the highlighting So, without resorting to inhibit-modification-hooks, it looks like you would need to test whether font-lock is currently turned on, and use a _different implementation_ accordingly. That seems absurd. I guess I may try doing something with overlays. BTW, what was wrong with the situation before -- where font-lock did its thing but didn't try to rule the roost, and gave you a way to _prevent it from refontifying_ -- when you knew it didn't need to refontify (or when you didn't want it to refontify)? Previously, function font-lock-after-fontify-buffer did the trick: it would tell font-lock that the buffer has already been fontified and doesn't need fontifying (until a buffer change is made). That function still exists, and it still does the same thing - but only for fast-lock and lazy-lock fontifying. Here's the code, including a commented-out part that suggests that someone once had it working for jit-lock too: (defun font-lock-after-fontify-buffer () (cond ((and (boundp 'fast-lock-mode) fast-lock-mode) (fast-lock-after-fontify-buffer)) ;; Useless now that jit-lock intercepts font-lock-fontify-buffer. -sm ;; (jit-lock-mode ;; (jit-lock-after-fontify-buffer)) ((and (boundp 'lazy-lock-mode) lazy-lock-mode) (lazy-lock-after-fontify-buffer)))) Shouldn't this function have the same effect in all font-lock modes, including jit-lock? Shouldn't it always tell the fontification code not to do anything until the buffer changes? The comment (yours, I guess) seems to indicate that this can't be done now (even if it should be done) because jit-lock intercepts font-lock-fontify-buffer. Does that mean that this function was neutered because of the way jit-lock happened to be implemented? Maybe this function can't do the trick anymore, but don't you think there should at least be a variable to calm font-lock down (like inhibit-modification-hooks, but affecting only fontification)? - Drew -----Original Message-----From: Stefan Monnier just do: (let ((inhibit-modification-hooks t)) (put-text-property start end 'face 'toto))