Subject: bug#192: regexp does not work as documented

From: Chong Yidong <[email-masked]>
Date: Tue, 06 May 2008 00:20:31 -0400

> $ emacs fr.po
> M-x highlight-regexp
>
> Regexp to highlight (enter this with Ctrl-Q Ctrl-J for each of the two
> newlines):
>
> ^msgstr\(\[[0-9]\]\)?.*
> \(".*
> \)*
>
> Highlight using face: hi-yellow
>
> Then move around in the buffer and look which lines are highlighted.
> In the first match already, only 5 out of 11 lines are highlighted.

I believe this bug arises because highlight-regexp uses font-lock to
highlight the regular expression, and the font-lock engine is
intentionally limiting the region to search for the multi-line regular
expression.

OTOH, I don't see what we can do about this problem.  Maybe we could add
a note to the docstring of highlight-regexp saying that multi-line
regular expressions are problematic?  Does anyone have a suggestion?

BTW, here is a simplified recipe, for those who didn't download the
attached file:

1. Copy the following text, between the "---...----" lines, into a
   buffer

------------------
# Messages français pour GNU gettext.
# Copyright © 2006 Free Software Foundation, Inc.
# François Pinard <[email-masked]>, 1996.
#
#
msgid ""
msgstr ""
"Project-Id-Version: GNU gettext-tools 0.16.2-pre5\n"
"Report-Msgid-Bugs-To: [email-masked]\n"
"POT-Creation-Date: 2007-11-02 03:23+0100\n"
"PO-Revision-Date: 2007-10-27 13:35+0200\n"
"Last-Translator: Christophe Combelles <[email-masked]>\n"
"Language-Team: French <[email-masked]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
------------------

2. M-: (highlight-regexp "^m.*\n\\(\".*\n\\)+") RET

Note that the last two lines remain unhighlighted.