Subject: Re: bug#41185: highlight-regexp not working properly for multiline-matching regexps

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 13 Jun 2021 13:37:31 +0200

Michael Heerdegen <[email-masked]> writes:

> jan <[email-masked]> writes:
>
>> Try to regexp-highlight particular preprocessor use:
>>
>> M-s h r def HALF_LJ[^^]+?# endif RET
>>
>> (the [^^] is because I want it to match multiline, and I don't expect
>> any carets in the text, so I negate that to allow newline matches and
>> make it lazy to pick out the shortest +?  It's sloppy but ok here)
>>
>> Does not highlight anything
>
> Yes, thanks.
>
> I can reproduce this.  I'm not a font-lock expert, but I suspect that
> hi-lock doesn't support patterns matching multi-line text.

I can reproduce what the original bug report is seeing -- but that's
because the regexp seems to be wrong?  There's nothing in the test file
that matches "# endif".

However the following call does properly match the region I think was
intended, and works fine, as far as I can see (in Emacs 26.1 and 28):

(highlight-regexp "def HALF_LJ[^^]+?# +endif")

Or do I misunderstand what the original problem was?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no