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: Wed, 26 Apr 2006 08:30:25 +0000 (GMT) Message-ID: References: <87u08harmc.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1146048086 20300 80.91.229.2 (26 Apr 2006 10:41:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 26 Apr 2006 10:41:26 +0000 (UTC) Cc: Richard Stallman , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 26 12:41:24 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 1FYhSV-00063G-Cn for ged-emacs-devel@m.gmane.org; Wed, 26 Apr 2006 12:41:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYhSV-0000TC-0l for ged-emacs-devel@m.gmane.org; Wed, 26 Apr 2006 06:41:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FYhRp-00007l-3L for emacs-devel@gnu.org; Wed, 26 Apr 2006 06:40:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FYhRo-00006u-NP for emacs-devel@gnu.org; Wed, 26 Apr 2006 06:40:40 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYhRo-00006k-Dl for emacs-devel@gnu.org; Wed, 26 Apr 2006 06:40:40 -0400 Original-Received: from [193.149.49.134] (helo=acm.acm) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FYhUR-0002dr-Ht; Wed, 26 Apr 2006 06:43:24 -0400 Original-Received: from localhost (root@localhost) by acm.acm (8.8.8/8.8.8) with SMTP id IAA00580; Wed, 26 Apr 2006 08:30:26 GMT X-Sender: root@acm.acm Original-To: Stefan Monnier In-Reply-To: <87u08harmc.fsf-monnier+emacs@gnu.org> 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:53461 Archived-At: Hi, Stefan! On Wed, 26 Apr 2006, Stefan Monnier wrote: >>> I'm not saying the hook is a kludge: I'm saying the code that uses it is >>> a kludge, compared to the code that uses font-lock-multiline. >> OK. I feel that existing code in AWK Mode is natural. (OK, I wrote it, >> so I'm not in a position to judge it dispassionately, but ...). It notes >> the logical EOL before a change. It notes the logical EOL after a >> change. The later one is the end position for fontification. >Why doesn't the BOL before change matter? Maybe it does/would do in some major modes. It happens not to have any effect in AWK. >Why does the EOL before change matter? Because a buffer change can alter this EOL's syntactic context. >> By contrast, the f-l-multiline method (ab)uses the structure for setting >> face properties to set region boundaries for possible future changes. >Abuses the structure of what? font-lock-keywords. The purpose of this structure is to fontify strings matching specific regular expressions. Using it to expand the region to be font-locked at a future fontification seems utterly disconnected with this purpose. >There two issues about multiline elements: >- properly notice them when they appear >- properly *re*fontify them when they change I cannot bring myself to consider the extension of a font lock region as "the manipulation of a multiline element". It just feels too contorted. I have always understood the term "multiline element" to mean an element within the font-lock region which crosses a line boundary. [Such things occur a lot in Texinfo Mode, for example, and turning on the f-l-multiline variable does indeed make these elements fontify properly.] >The first is taken care of by font-lock-fontify-region-function. The AWK Mode regular expressions, even those that can straddle line breaks, match just fine without having to turn on the f-l-multiline variable. >The second talks about *re*fontification, so it's natural that it would >involves saving some info during fontification for the next time around. I think I would agree, except that font-lock brutally erases these properties at every fontification, only to have to recalculate them. This wastes processor time, probably quite a lot of it. What is the point of doing this, unless there has been a buffer change? The same applies to the syntax-table property. >Doing it in a-c-f is fundamentally not the right place since it doesn't >know whether and how the changed text was fontified: it works, of >course, but it's not particularly more natural. To know how text is to be refontified, you need to know how it has been changed. before/after-change-functions is a perfectly natural place to find this out. > Stefan -- Alan.