From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [sigra@home.se: C++-mode: Syntax highlighting: wrong color for function identifier depending on the kind of whitespace that follows] Date: Thu, 10 Mar 2005 08:01:53 -0500 Message-ID: <87u0nj7jds.fsf-monnier+emacs@gnu.org> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1110459917 1827 80.91.229.2 (10 Mar 2005 13:05:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 10 Mar 2005 13:05:17 +0000 (UTC) Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 10 14:05:17 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D9NLc-0007d7-Sa for ged-emacs-devel@m.gmane.org; Thu, 10 Mar 2005 14:05:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D9NaV-0000rP-15 for ged-emacs-devel@m.gmane.org; Thu, 10 Mar 2005 08:20:27 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D9NXW-0007X3-3T for emacs-devel@gnu.org; Thu, 10 Mar 2005 08:17:22 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D9NXR-0007Ut-E6 for emacs-devel@gnu.org; Thu, 10 Mar 2005 08:17:18 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D9NXR-0007UU-5k for emacs-devel@gnu.org; Thu, 10 Mar 2005 08:17:17 -0500 Original-Received: from [209.226.175.93] (helo=tomts36-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1D9NIa-0001Wf-FY; Thu, 10 Mar 2005 08:01:56 -0500 Original-Received: from alfajor ([65.92.241.52]) by tomts36-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20050310130155.MRWH1694.tomts36-srv.bellnexxia.net@alfajor>; Thu, 10 Mar 2005 08:01:55 -0500 Original-Received: by alfajor (Postfix, from userid 1000) id D02A3D74A3; Thu, 10 Mar 2005 08:01:53 -0500 (EST) Original-To: Alan Mackenzie In-Reply-To: (Alan Mackenzie's message of "Thu, 10 Mar 2005 08:00:42 +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 X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: news.gmane.org gmane.emacs.devel:34416 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34416 > We talked about it in bug-cc-mode just after CC Mode 5.30 had been > released. (Subject: Advising in cc-awk.el and namespace Date: Wed, 09 > Jul 2003 13:20:20 -0400). I drew attention then (Jul 2003) to the patch > I had submitted in 2002, which you acknowledged. However, the topic of > conversation drifted onto why jit-lock consumed so much processor power. Ah...topic drift. Sorry about not being more careful. >> Could you explain some more about your two cases (the one in awk and the >> one in the subject of this article): >> - how do they use your new before-font-lock-after-change-function hook? > The one in AWK is with a string like this: > print "multi-l\ > ine\ > string > ^ > | > point > The opening quote has been given warning font, since it is an unmated > quote. When the closing quote is typed, the opening quote's face gets > changed to string face. This is done by the advice on > font-lock-after-change-function (or the jit-lock thingy ...) amending the > BEGIN parameter to point to the start of the "print" line, before passing > this into font-lock. > The C example at the top is essentially the same; the single line > containing "(int x);" currently gets fontified by after-change in > isolation; correct fontification requires that it be fontified with the > previous line as a unit. > The patch I proposed would achieve this result via a user supplied > function. Well my question was really about "how" rather than "why": what does the elisp hook code look like for each of the two cases. >> - why can't they use the font-lock-multiline property? > I couldn't find any documentation for the facility back in 2002, and I > couldn't figure out from the source code exactly what it did. I've now > got it working for me in Texinfo mode, though. > Also, font-lock-multiline doesn't (yet?) exist in XEmacs, so I'd need to > implement a second solution for XEmacs if f-l-multiline was used. CC > Mode still supports Emacs 20.x, and I think I found that f-l-multiline > was introduced later than 20.1 (though I can't remember exactly). Your new hook won't exist in Emacs-20 either, so this seems irrelevant to the discussion at hand. It just risks drifting the topic. >> - why can't they use the jit-lock-defer-multiline property? > I'll have to look at that one. But presumably that doesn't exist in both > of XEmacs and Emacs 20.x either. Again, irrelevant. > I think, as I have done since 2002, that the major-mode should be able to > supply functions to determine the start and end of the region to be > fontified. It seems a natural and idiomatic Emacsy way of doing things. You may be right, but I'd like to see your code first, to see how easy and robust it is to use your hook. On a side note, I'm wondering why you go through so much trouble with the "unmatched opening quote" in AWK. No other mode does that AFAIK, even though pretty much every major mode in lisp/progmodes/ has pretty much the same need AFAICT. Does it have to do with something specific to AWK, or is it non-specific and maybe it should be done for all modes? Stefan