[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to highlight-regexp across multiple lines
From: |
Nicolas Richard |
Subject: |
Re: How to highlight-regexp across multiple lines |
Date: |
Fri, 04 Apr 2014 12:49:03 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Angus Comber <anguscomber@gmail.com> writes:
> I was looking at this question on stackoverflow and it seems regex can
> select across multiple lines generally but how would I do so for
> highlight-regexp in emacs?
>
> http://stackoverflow.com/questions/159118/how-do-i-match-any-character-across-multiple-lines-in-a-regular-expression
>
>
> Eg I want to highlight ALL text from aPDU... to the final closing brace:
interactively, you enter the string it as follows:
a P D U [ ^ C-q 0 RET ] + C-q C-j } RET
in elisp it gives:
(highlight-regexp "aPDU[^\000]+?\n}" (quote hi-yellow))
C-q 0 RET inserts a character which has '0' as octal (or whatevervalue
read-quoted-char-radix is) representation, that's the NUL character that
Thorsten mentionned. This is equivalent to "\000" in elisp.
C-q C-j inserts a new line character (simply hitting RET would terminate
the prompt, so that's not an option). This is equivalent to "\n" in elisp.
The idea is : highlight *everything* lazily from the string "aPDU" up to
the first sequence "newline-closing brace".
HTH,
--
Nico.
Re: How to highlight-regexp across multiple lines,
Nicolas Richard <=