From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thorsten Jolitz Newsgroups: gmane.emacs.help Subject: Re: How to highlight-regexp across multiple lines Date: Thu, 03 Apr 2014 21:21:00 +0200 Message-ID: <87eh1ei5ib.fsf@gmail.com> References: <87ioqqih7n.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1396552822 964 80.91.229.3 (3 Apr 2014 19:20:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 3 Apr 2014 19:20:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 03 21:20:16 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WVnBO-0007Qp-LW for geh-help-gnu-emacs@m.gmane.org; Thu, 03 Apr 2014 21:20:14 +0200 Original-Received: from localhost ([::1]:45930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVnBO-0008KV-3L for geh-help-gnu-emacs@m.gmane.org; Thu, 03 Apr 2014 15:20:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVnB6-0008IT-Tu for help-gnu-emacs@gnu.org; Thu, 03 Apr 2014 15:20:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVnB0-0007TR-RI for help-gnu-emacs@gnu.org; Thu, 03 Apr 2014 15:19:56 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:50670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVnB0-0007TF-KC for help-gnu-emacs@gnu.org; Thu, 03 Apr 2014 15:19:50 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WVnAz-00073q-EC for help-gnu-emacs@gnu.org; Thu, 03 Apr 2014 21:19:49 +0200 Original-Received: from g231227208.adsl.alicedsl.de ([92.231.227.208]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Apr 2014 21:19:49 +0200 Original-Received: from tjolitz by g231227208.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Apr 2014 21:19:49 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 85 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: g231227208.adsl.alicedsl.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:sct0wegnNus4FhYrZ93EY7mpe/c= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96950 Archived-At: Angus Comber writes: > It seems that it matches the aPDU messages provided there is no 0 in the > text. I am puzzled by the [^\\000] - where can I find documentation on it? Thats stolen from the Org-mode sources, and I asked the same question before ;) Here is Carsten Dominik's answer: ,---------------------------------------------------------------------------- | > PS | > Can anybody explain this marvelous construct in the regexp: | > | > ,--------- | > | [^\\000] | > `--------- | | This is just a cheep way to match any character at all, because \000 should | not be part of any string (in C it indicates the end of a string). | In principle you could put any character you are sure will not turn up, | but \000 seems to be the safest choice. It is | faster (I think) than "\\(.\\|\n\\)*" because the first will | just run fast and streight with a table lookup while the | latter need to always alternate between two alternatives. | I have not timed it, though. `---------------------------------------------------------------------------- > Is it not null or something like that? But then why does it not capture > string "0"? This happened to me to, although I think it shouldn't. But when I used it with M-x regexp-builder it worked. With M-x reb-copy (and then paste), the [^\\000] is transformed to a different representation - maybe you could try reb-copy & paste it into your function and see if it works then? > On 3 April 2014 16:08, Thorsten Jolitz wrote: > >> Angus Comber 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: >> > >> > aPDU-rose : retResult : { >> > invokeID 2, >> > operValue { >> > operationValue local : 71, >> > result { >> > crossRefIdentifier '40 3f'H >> > } >> > } >> > } >> > >> > >> > How would I do that using highlight-regexp? >> > >> > highlight-regexp aPDU-rose.* hi-yellow would get me the first line - but >> > how to get everything including last } character? >> >> This regexp did match the aPDU in the gnus *Article* buffer: >> >> ,-------------------- >> | "^aPDU[^\\000]+[}]+?$" >> `-------------------- >> >> -- >> cheers, >> Thorsten >> >> >> > -- cheers, Thorsten