From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#20146: font-lock-extend-jit-lock-region-after-change: results are discarded instead of being returned. Date: Sat, 21 Mar 2015 10:58:41 +0000 Message-ID: <20150321105841.GA3001@acm.fritz.box> References: <20150319230136.GC2753@acm.fritz.box> <20150320160744.GA3493@acm.fritz.box> <20150321000003.GF3493@acm.fritz.box> <550CC42F.7050302@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1426935636 22091 80.91.229.3 (21 Mar 2015 11:00:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Mar 2015 11:00:36 +0000 (UTC) Cc: 20146@debbugs.gnu.org To: Daniel Colascione Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 21 12:00:20 2015 Return-path: Envelope-to: geb-bug-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 1YZH8Y-0007kL-La for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Mar 2015 12:00:14 +0100 Original-Received: from localhost ([::1]:47412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZH8X-00036B-Kn for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Mar 2015 07:00:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZH8U-00035A-DK for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2015 07:00:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YZH8P-0004qp-A0 for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2015 07:00:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZH8P-0004pl-7N for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2015 07:00:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YZH8O-00017O-FJ for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2015 07:00:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Mar 2015 11:00:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20146 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20146-submit@debbugs.gnu.org id=B20146.14269355454193 (code B ref 20146); Sat, 21 Mar 2015 11:00:04 +0000 Original-Received: (at 20146) by debbugs.gnu.org; 21 Mar 2015 10:59:05 +0000 Original-Received: from localhost ([127.0.0.1]:59608 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YZH7R-00015Y-3M for submit@debbugs.gnu.org; Sat, 21 Mar 2015 06:59:05 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:51390 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YZH7O-000156-Fo for 20146@debbugs.gnu.org; Sat, 21 Mar 2015 06:59:03 -0400 Original-Received: (qmail 16465 invoked by uid 3782); 21 Mar 2015 10:59:01 -0000 Original-Received: from acm.muc.de (pD951A26C.dip0.t-ipconnect.de [217.81.162.108]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 21 Mar 2015 11:58:58 +0100 Original-Received: (qmail 3187 invoked by uid 1000); 21 Mar 2015 10:58:41 -0000 Content-Disposition: inline In-Reply-To: <550CC42F.7050302@dancol.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:100741 Archived-At: Hello, Daniel. On Fri, Mar 20, 2015 at 06:06:55PM -0700, Daniel Colascione wrote: > On 03/20/2015 05:00 PM, Alan Mackenzie wrote: > >> The existence of font-lock-extend-after-change-region-function is an > >> error on my part (More specifically the result of a weakness on my part: > >> when you requested this feature, I added > >> font-lock-extend-region-function (which was the right fix) and > >> reluctantly accepted to also add > >> font-lock-extend-after-change-region-function just out of tiredness of > >> arguing that it was the wrong solution). > > Yes, it was an exhausting discussion back in 2006. But > > f-l-extend-after-change-r-f works well. If you change the interface to > > have only font-lock-extend-region-functions, then you rule out what > > somebody (was it Daniel?) recently called "edge triggered" fontification, > > leaving only "level triggered". > > AWK Mode (if not others) uses edge triggered fontification: For the > > calculation of its FL region, it uses `beg' and `end' from > > before-change-functions and `beg', `end', and `old-len' from > > after-change-functions. If f-l-extend-after-change-r-f vanishes, some > > other means will have to be found to transmit this info to Font Lock - > > the ugly advice used by earlier Emacs versions, for example. > Level-triggered fontification is the only correct scheme. Can you offer any evidence, or argumentation for this opinion? As I said, edge-triggered fontification works in AWK Mode and works well. I'm not quite sure at the moment whether the other CC Mode modes use it. > You don't need fine-grained control over the font-lock region. Major modes need absolute control over where font-locking analysis starts - they must be able to chose a position with a neutral syntactic context. For example, when Font Lock asks for fontification starting in the inside of a C++ declaration, C++ Mode needs to be able to say STOP! GO BACK! CARRY ON! > You need better cache invalidation. When, where, of what? > Font-lock can ask for the right to ask for the fontification of any > range of characters. If I want to, I can install customization that > changes the font-lock region to a whole paragraph, a whole defun, or a > whole file. None of that should matter. Of course. But AFTER that selection, the major mode decides where to start analysing based on the selection. As I pointed out to Stefan, we don't distinguish between "place to start analysing" and "place to start applying face properties", so we can only talk about "the Font Lock region". I think the critical point is: Several things can choose, expand (?or contract) a region to fontify. But the major mode must be the last entity that does so. > Some modes might have caches that reflect buffer contents --- they > should invalidate these caches in before- and after-change-functions, > before font-lock even runs. Not quite sure exactly what sort of caches you're thinking about, but they will get updated, rather than invalidated, in the before/after-change-functions functions, surely? > Let me put it another way: a highlighter's job is to find the correct > face for a given buffer position. In order to not drive the user insane, > that face must be a function solely of the contents of the buffer and > cached information about the contents of the buffer. Otherwise, > fontification will change depending on scrolling, jit-lock chunk size, > and other factors. None of these things should affect the faces that we > ultimately apply to characters. Of course. But they affect the way we calculate those faces. > Maybe we should have some tests that do fontification one character at a > time, or in random order. Now there's an idea. :-) -- Alan Mackenzie (Nuremberg, Germany).