From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Last steps for pretesting (font-lock-extend-region-function) Date: Tue, 25 Apr 2006 22:16:23 +0000 (GMT) Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1146005847 29169 80.91.229.2 (25 Apr 2006 22:57:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 25 Apr 2006 22:57:27 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 26 00:57:25 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FYWTD-0005Xd-D5 for ged-emacs-devel@m.gmane.org; Wed, 26 Apr 2006 00:57:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYWTD-0002bD-2l for ged-emacs-devel@m.gmane.org; Tue, 25 Apr 2006 18:57:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FYWSM-0002C9-8S for emacs-devel@gnu.org; Tue, 25 Apr 2006 18:56:30 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FYWSL-0002Bt-T9 for emacs-devel@gnu.org; Tue, 25 Apr 2006 18:56:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYWSL-0002Bq-MD for emacs-devel@gnu.org; Tue, 25 Apr 2006 18:56:29 -0400 Original-Received: from [193.149.49.134] (helo=acm.acm) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FYWUt-0004EM-4x for emacs-devel@gnu.org; Tue, 25 Apr 2006 18:59:08 -0400 Original-Received: from localhost (root@localhost) by acm.acm (8.8.8/8.8.8) with SMTP id WAA00398; Tue, 25 Apr 2006 22:16:24 GMT X-Sender: root@acm.acm Original-To: Ralf Angeli In-Reply-To: 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:53429 Archived-At: Hi, Ralf! On Tue, 25 Apr 2006, Ralf Angeli wrote: >* Alan Mackenzie (2006-04-24) writes: >> after-change-functions is the canonical way of solving problems related >> to buffer changes. This includes Font Locking. >But extending the region in the after-change case does not help with >"normal" fontification by region as e.g. done by jit-lock. >> I say to you again - your solution is not robust. I don't think it's >> been tried at all (correct me if I'm wrong). >Hopefully I understand "your solution" correctly here if I am assuming >this relates to putting the hook into >`font-lock-default-fontify-region'. Yes - more precisely, putting the hook ONLY into f-l-d-f-r. >I've implemented a variant of this approach for AUCTeX by using a >custom-made function for `font-lock-fontify-region-function' which calls >other functions for extending the region and then calls >`font-lock-default-fontify-region' with the extended region as >arguments. There is no special code in `after-change-functions' and the >approach actually works quite well. >> We are both aware of a refinement which is needed, namely calling some >> sort of f-l-extend-region-f from f-l-d-f-r and j-l-f-n. >If putting the hook into `font-lock-default-fontify-region' works >reliably, why do you need it in `after-change-functions' and >`jit-lock-fontify-now' as well? It doesn't work reliably. The region which needs fontification after a buffer change depends on that _change_, not merely on what the buffer looks like after the change. If the f-l-extend-region-f isn't called from after-change-functions, necessary information gets lost. Take, once more, the standard canonical example: 1: "string \ 2: over \ 3: several <======= point is here, having just deleted a character. 4: lines." Point is at EOL 3, having just deleted a character. A hook in f-l-after-change-functions cannot determine whether L4 belongs to the region, without knowing whether the deleted character was a \. A hook is thus necessary in font-lock-after-change-functions too, to record this information in some fashion. >Ralf -- Alan.