From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Koppelman Newsgroups: gmane.emacs.devel Subject: Re: regexp does not work as documented Date: Sun, 11 May 2008 10:36:49 -0500 Message-ID: References: <87k5i8ukq8.fsf@stupidchicken.com> <200805061335.11379.bruno@clisp.org> <48204B3D.6000500@gmx.at> <4826A303.3030002@gmx.at> <87abiwoqzd.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1210520230 21185 80.91.229.12 (11 May 2008 15:37:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 11 May 2008 15:37:10 +0000 (UTC) Cc: martin rudalics , 192@emacsbugs.donarmstrong.com, Bruno Haible , emacs-devel@gnu.org To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 11 17:37:48 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JvDcR-0002fi-9k for ged-emacs-devel@m.gmane.org; Sun, 11 May 2008 17:37:47 +0200 Original-Received: from localhost ([127.0.0.1]:34526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JvDbi-0001T9-Hw for ged-emacs-devel@m.gmane.org; Sun, 11 May 2008 11:37:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JvDbe-0001Sa-MZ for emacs-devel@gnu.org; Sun, 11 May 2008 11:36:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JvDbd-0001SG-WE for emacs-devel@gnu.org; Sun, 11 May 2008 11:36:58 -0400 Original-Received: from [199.232.76.173] (port=56071 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JvDbd-0001SD-RY for emacs-devel@gnu.org; Sun, 11 May 2008 11:36:57 -0400 Original-Received: from ecelsrv1.ece.lsu.edu ([130.39.223.98]:53773) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JvDbd-0005SR-9W for emacs-devel@gnu.org; Sun, 11 May 2008 11:36:57 -0400 Original-Received: from localhost (unknown [127.0.0.1]) by ecelsrv1.ece.lsu.edu (Postfix) with ESMTP id 6B1DB2833D; Sun, 11 May 2008 15:36:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at ece.lsu.edu Original-Received: from ecelsrv1.ece.lsu.edu ([127.0.0.1]) by localhost (ecelsrv1.ece.lsu.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wJjrDJ2jbWh7; Sun, 11 May 2008 10:36:49 -0500 (CDT) Original-Received: from nested.ece.lsu.edu (nested.ece.lsu.edu [130.39.222.143]) by ecelsrv1.ece.lsu.edu (Postfix) with ESMTP id BDC2428316; Sun, 11 May 2008 10:36:49 -0500 (CDT) In-Reply-To: <87abiwoqzd.fsf@stupidchicken.com> (Chong Yidong's message of "Sun, 11 May 2008 10:27:50 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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:96971 Archived-At: I agree pretty much with everything Chong Yidong writes. I rather not bother the user with an additional question if I don't have to, the alternative would be a warning. My latest plan is to do what Chong Yidong suggests, setting up text properties so that font-lock DTRT, though it doesn't seem as hard as he suggests (I'm still in the naive enthusiasm stage). I tried adding the font-lock-multiline property to the face property list passed to font lock and that did the trick, even with the font-lock-multiline variable nil. I rather do that than turn on font-lock-multiline because I'm assuming that font-lock-multiline is set to nil in most cases for a good reason. Rather than perfectly distinguishing multi-line from single line patterns guessing would be good enough for hi-lock. I'm using the following regexp, "\\(\n.\\|\\\\W[*+]\\|\\\\[SC].[*+]\\|\\[\\^[^]]+\\][+*]\\)", which hopefully isn't too far from covering a large majority of interactively entered patterns. I actually thought about properly parsing the regexp, but the effort to do that could be spent on making multi-line patterns work properly, at least if they don't span too many lines. One more thing, multi-line regexp matches don't work properly even with font-lock-multiline t when jit-lock is being used in a buffer without syntactic fontification and using the default setting of jit-lock-contextually, setting it to t gets multi-line fontification to work. I plan to play around a bit more and come up with something, maybe today, maybe early this week. Chong Yidong writes: > Ideally, highlight-regexp should work automagically, instead of forcing > users to do something extra to make their multi-line regexp work > properly. The right way to do this is probably for hi-lock-mode to > process the buffer initially, setting up text properties to make > font-lock DTRT even for multi-line expressions. But that's a big job. > > As for making hi-lock-mode detect whether or not a regexp is multi-line, > isn't that a computationally non-trivial problem? > > Maybe making hi-lock-mode turn on font-lock-multiline, while not > foolproof, works often enough to be satisfactory.