From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?GB2312?B?zcHQx87lusU=?= Newsgroups: gmane.emacs.help Subject: Re: does emacs regular expression support (?!expression) Date: Fri, 3 Feb 2012 10:12:27 +0800 Message-ID: References: <8739at5aj0.fsf@thinkpad.tsdh.de> <87ipjo52qn.fsf@thinkpad.tsdh.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0015174be78284468c04b805daa8 X-Trace: dough.gmane.org 1328235201 6692 80.91.229.3 (3 Feb 2012 02:13:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 3 Feb 2012 02:13:21 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Kevin Rodgers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 03 03:13:21 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rt8eO-0004Wq-UQ for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Feb 2012 03:13:21 +0100 Original-Received: from localhost ([::1]:38947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rt8eJ-0007zc-SZ for geh-help-gnu-emacs@m.gmane.org; Thu, 02 Feb 2012 21:13:15 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:46161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rt8eF-0007z3-6w for help-gnu-emacs@gnu.org; Thu, 02 Feb 2012 21:13:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rt8eD-000462-Ik for help-gnu-emacs@gnu.org; Thu, 02 Feb 2012 21:13:11 -0500 Original-Received: from mail-ey0-f169.google.com ([209.85.215.169]:38716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rt8eD-00045x-AC for help-gnu-emacs@gnu.org; Thu, 02 Feb 2012 21:13:09 -0500 Original-Received: by eaag11 with SMTP id g11so1248496eaa.0 for ; Thu, 02 Feb 2012 18:13:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=en+Sghb197hi6cdqZ5FuGDPAphnG+xP8hOSnR4qd7KI=; b=i8T7KbhkpVkkxd7CzntpVAGb5rO8xycB9KBBUtmirAy7UWl2a64pqh/eObQrRm9mko qzTPtjkmZPaEtRnJ+OyFDQKpaDjwS32k0CjY4jo/EeDH9KNvPPFrGET5iWobB5ErVevy gBNyAeCOPF69ll+GZ+m8T1LxdwJNniQWIbjmE= Original-Received: by 10.213.22.74 with SMTP id m10mr901330ebb.32.1328235187291; Thu, 02 Feb 2012 18:13:07 -0800 (PST) Original-Received: by 10.14.101.5 with HTTP; Thu, 2 Feb 2012 18:12:27 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.215.169 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:83594 Archived-At: --0015174be78284468c04b805daa8 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: quoted-printable I would like match Err in any words(e.g. LastError), but not ErrorMode. (defvar txt-mode-font-lock-keywords `( ;; =CE=C4=BC=FE=C3=FB ("\\\\\\(\\w+\\.exe\\)" 1 font-lock-keyword-face) ;; IP=BA=CD=B0=E6=B1=BE ("[^0-9]\\([0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\= }\\)" 1 font-lock-keyword-face) ;; Error ("\\<\\([Dd][Bb][Ee][Rr][Rr][Oo][Rr]\\)\\>" 1 font-lock-warning-face) ("\\<\\([Dd][Bb][Ee][Rr][Rr]\\)\\>" 1 font-lock-warning-face) ("\\<\\([Ee][Rr][Rr][Oo][Rr]\\)\\>" 1 font-lock-warning-face) ("\\([Ee][Rr][Rr]\\)\\(?!orMode\\)" 1 font-lock-warning-face) ("\\(=B4=ED=CE=F3\\)" 1 font-lock-warning-face) ("\\(=CA=A7=B0=DC\\)" 1 font-lock-warning-face) ("\\(=D1=CF=D6=D8\\)" 1 font-lock-warning-face) ("\\<\\([Ff][Aa][Ii][Ll][Ee][Dd]\\)\\>" 1 font-lock-warning-face) ("\\<\\([Ff][Aa][Ii][Ll]\\)\\>" 1 font-lock-warning-face) ("\\<\\([Cc][Aa][Nn]\\s+[Nn][Oo][Tt]\\)\\>" 1 font-lock-warning-face) ("\\<\\([Cc][Aa][Nn]'[Tt]\\)\\>" 1 font-lock-warning-face) ("\\<\\([Ww][Rr][Oo][Nn][Gg]\\)\\>" 1 font-lock-warning-face) ;; Warning ("\\<\\([Ww][Aa][Rr][Nn][Ii][Nn][Gg]\\)\\>" 1 font-lock-warning-face) ("\\<\\([Ww][Aa][Rr][Nn]\\)\\>" 1 font-lock-warning-face) ("\\(=BE=AF=B8=E6\\)" 1 font-lock-warning-face) ;; Exception ("\\<\\([Ee][Xx][Cc][Ee][Pp][Tt][Ii][Oo][Nn]\\)\\>" 1 font-lock-warning-face) ("\\<\\([Ee][Xx][Cc][Ee][Pp][Tt]\\)\\>" 1 font-lock-warning-face) ("\\(=D2=EC=B3=A3\\)" 1 font-lock-warning-face) ) "Basic font lock keywords for txt mode. Highlights keywords.") 2012/2/3 Kevin Rodgers > On 2/2/12 2:45 PM, Tassilo Horn wrote: > >> Tim Landscheidt> >> writes: >> > > In Perl, "(?!pattern)" is a zero-width negative look-ahead >>> assertion. Emacs does not support these AFAIK. >>> >> >> I see. So when you do /foo(?!bar)/ in Perl, you'd need to do >> "foo\\(?:[^b][^a][^r]\\)" in elisp. >> > > IIUC, the Perl regex would successfully match "foo" if it were followed b= y > "far", but the Emacs regexp would not. > > Maybe \(?:[^b][^a][^r]\) should be \(?:[^b]\|b[^a]\|ba[^r]\) > > -- > Kevin Rodgers > Denver, Colorado, USA > > > --0015174be78284468c04b805daa8 Content-Type: text/html; charset=GB2312 Content-Transfer-Encoding: quoted-printable I would like match Err in any words(e.g. LastError), but not ErrorMode.
= (defvar txt-mode-font-lock-keywords
  `(
    ;; = =CE=C4=BC=FE=C3=FB
    ("\\\\\\(\\w+\\.exe\\)" = 1 font-lock-keyword-face)
    ;; IP=BA=CD=B0=E6=B1=BE
=     ("[^0-9]\\([0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\= \{1,3\\}\\.[0-9]\\{1,3\\}\\)" 1 font-lock-keyword-face)
    ;; Error
    ("\\<\\([Dd][Bb][= Ee][Rr][Rr][Oo][Rr]\\)\\>" 1 font-lock-warning-face)
  = ;  ("\\<\\([Dd][Bb][Ee][Rr][Rr]\\)\\>" 1 font-lock-war= ning-face)
    ("\\<\\([Ee][Rr][Rr][Oo][Rr]\\)\\&= gt;" 1 font-lock-warning-face)
    ("\\([Ee][Rr][Rr= ]\\)\\(?!orMode\\)" 1 font-lock-warning-face)
  &n= bsp; ("\\(=B4=ED=CE=F3\\)" 1 font-lock-warning-face)
 &nb= sp;  ("\\(=CA=A7=B0=DC\\)" 1 font-lock-warning-face)
    ("\\(=D1=CF=D6=D8\\)" 1 font-lock-warning-face= )
    ("\\<\\([Ff][Aa][Ii][Ll][Ee][Dd]\\)\\>&q= uot; 1 font-lock-warning-face)
    ("\\<\\([Ff][A= a][Ii][Ll]\\)\\>" 1 font-lock-warning-face)
    ("\\<\\([Cc][Aa][Nn]\\s+[Nn][Oo][Tt]\\)\\>&qu= ot; 1 font-lock-warning-face)
    ("\\<\\([Cc][Aa= ][Nn]'[Tt]\\)\\>" 1 font-lock-warning-face)
  &nbs= p; ("\\<\\([Ww][Rr][Oo][Nn][Gg]\\)\\>" 1 font-lock-warning-= face)
    ;; Warning
    ("\\<\\([Ww][Aa= ][Rr][Nn][Ii][Nn][Gg]\\)\\>" 1 font-lock-warning-face)
 &nb= sp;  ("\\<\\([Ww][Aa][Rr][Nn]\\)\\>" 1 font-lock-warni= ng-face)
    ("\\(=BE=AF=B8=E6\\)" 1 font-lock-= warning-face)
    ;; Exception
    ("\\<\\([Ee][= Xx][Cc][Ee][Pp][Tt][Ii][Oo][Nn]\\)\\>" 1 font-lock-warning-face)    ("\\<\\([Ee][Xx][Cc][Ee][Pp][Tt]\\)\\>"= 1 font-lock-warning-face)
    ("\\(=D2=EC=B3=A3\\)&= quot; 1 font-lock-warning-face)
    )
  "Basic font lock keywords for txt mode.=   Highlights keywords.")

2012/2= /3 Kevin Rodgers <kevin.d.rodgers@gmail.com>
On 2/2/12 2:45 PM, Tassilo Horn wrote:
Tim Landscheidt<tim@tim-landscheidt.de>  writes:

In Perl, "(?!pattern)" is a zero-width negative look-ahead
assertion.  Emacs does not support these AFAIK.

I see.  So when you do /foo(?!bar)/ in Perl, you'd need to do
"foo\\(?:[^b][^a][^r]\\)" in elisp.

IIUC, the Perl regex would successfully match "foo" if it were fo= llowed by
"far", but the Emacs regexp would not.

Maybe \(?:[^b][^a][^r]\) should be \(?:[^b]\|b[^a]\|ba[^r]\)

--
Kevin Rodgers
Denver, Colorado, USA



--0015174be78284468c04b805daa8--