From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Last steps for pretesting (font-lock-extend-region-function) Date: Tue, 25 Apr 2006 13:59:01 +0200 Message-ID: <85y7xtuare.fsf@lola.goethe.zz> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1145966602 13857 80.91.229.2 (25 Apr 2006 12:03:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 25 Apr 2006 12:03:22 +0000 (UTC) Cc: emacs-devel@gnu.org, Stefan Monnier , Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 25 14:03:19 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 1FYMG1-0002th-GI for ged-emacs-devel@m.gmane.org; Tue, 25 Apr 2006 14:03:06 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYMG0-000632-P3 for ged-emacs-devel@m.gmane.org; Tue, 25 Apr 2006 08:03:04 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FYMEc-0005PH-6s for emacs-devel@gnu.org; Tue, 25 Apr 2006 08:01:38 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FYMEa-0005ND-Co for emacs-devel@gnu.org; Tue, 25 Apr 2006 08:01:36 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYMEZ-0005Mr-N6 for emacs-devel@gnu.org; Tue, 25 Apr 2006 08:01:35 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FYMH1-00016m-GW for emacs-devel@gnu.org; Tue, 25 Apr 2006 08:04:07 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1FYMER-000673-4S; Tue, 25 Apr 2006 08:01:28 -0400 Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id 518E51CFF985; Tue, 25 Apr 2006 13:59:01 +0200 (CEST) Original-To: Alan Mackenzie In-Reply-To: (Alan Mackenzie's message of "Tue, 25 Apr 2006 11:33:55 +0000 (GMT)") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:53374 Archived-At: Alan Mackenzie writes: > On Mon, 24 Apr 2006, Stefan Monnier wrote: [...] > I find the elisp manual page which describes font-lock-keywords > ("Search-based Fontification") all but inpenetrable. It's reduced me to > tears on several occasions. I've just spent five minutes looking through > it, trying to find the description of the form you suggested to me: > > (".*\\\\\n.*" > (0 (progn (put-text-property (match-beginning 0) (match-end 0) > 'font-lock-multiline t) > nil))) > > . I didn't find it. > [...] >>You don't have to be familiar with the internals. At least not more >>than necessary to write the proper foo-before-change-function plus >>foo-font-lock-lock-extend-region-after-change. > > With respect, Stefan, that's rubbish. You need to know where and how to > write the above Lisp form (the one starting (".*\\\\n.*" ...)) into > f-l-keywords. For me, that's perhaps half an hour to an hour of > frustration trying to find the right place in "Search-based > Fontification". [...] >>Here's my alternative implementation: > >> (defconst c-awk-font-lock-keywords >> '(... >> (".*\\\\\n.*" >> (0 (progn (put-text-property (match-beginning 0) (match-end 0) >> 'font-lock-multiline t) >> nil))) >> ...)) > >>Now which one's more direct and simple, really? > > The one which is adequately commented. Not relevant. > The one which doesn't use an obscure list structure that you need to > look up in a manual. The one with thin, obvious interfaces with the > rest of Emacs. It appears to me like you are uncomfortable around font lock expressions. And I doubt that anybody having worked with font lock entries and syntax table entries has not teared out his hairs in frustration several times round. But I don't think that the solution is trying to move everything somewhere else. It would rather be sensible to create appropriate accessor functions that save the programmer from having to deal with the internal list structures. We do similar things with the "event" data structure by having posn-* accessor functions. font-lock should be made more programmer-friendly instead of delegating stuff to various ad-hoc hooks. > I've tried, but I just don't have the intellectual capability to > cope with such complexity without the greatest of difficulty. You > obviously do. Complicated nested structures make my eyes glaze > over. There's a good chance I'm not the only Emacs hacker who has > this sort of trouble. Then we need to create functions or macros that build and access the data structures. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum