From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Koppelman Newsgroups: gmane.emacs.bugs Subject: bug#192: 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> Reply-To: David Koppelman , 192@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1210528566 11606 80.91.229.12 (11 May 2008 17:56:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 11 May 2008 17:56:06 +0000 (UTC) Cc: 192@emacsbugs.donarmstrong.com, Bruno Haible , emacs-devel@gnu.org To: Chong Yidong Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun May 11 19:56:43 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JvFms-00053Y-Cw for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 May 2008 19:56:42 +0200 Original-Received: from localhost ([127.0.0.1]:52221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JvFm9-00018h-QR for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 May 2008 13:55:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JvDpv-0005nl-Oe for bug-gnu-emacs@gnu.org; Sun, 11 May 2008 11:51:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JvDpu-0005mw-53 for bug-gnu-emacs@gnu.org; Sun, 11 May 2008 11:51:43 -0400 Original-Received: from [199.232.76.173] (port=58140 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JvDpt-0005mt-Vw for bug-gnu-emacs@gnu.org; Sun, 11 May 2008 11:51:42 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:44488) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JvDpt-0007jk-1P for bug-gnu-emacs@gnu.org; Sun, 11 May 2008 11:51:41 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4BFpdBd030268; Sun, 11 May 2008 08:51:39 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m4BFj2fE029080; Sun, 11 May 2008 08:45:02 -0700 X-Loop: don@donarmstrong.com Resent-From: David Koppelman Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sun, 11 May 2008 15:45:02 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 192 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 192-submit@emacsbugs.donarmstrong.com id=B192.121052021428413 (code B ref 192); Sun, 11 May 2008 15:45:02 +0000 Original-Received: (at 192) by emacsbugs.donarmstrong.com; 11 May 2008 15:36:54 +0000 Original-Received: from ecelsrv1.ece.lsu.edu (ecelsrv1.ece.lsu.edu [130.39.223.98]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4BFao0n028407 for <192@emacsbugs.donarmstrong.com>; Sun, 11 May 2008 08:36:51 -0700 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 (newer, 3) Resent-Date: Sun, 11 May 2008 11:51:43 -0400 X-Mailman-Approved-At: Sun, 11 May 2008 13:55:34 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:17959 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.