help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with regexp


From: tomas
Subject: Re: Help with regexp
Date: Sat, 5 Dec 2009 07:46:08 +0100
User-agent: Mutt/1.5.15+20070412 (2007-04-11)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Dec 02, 2009 at 09:14:30AM +0100, Andreas Politz wrote:
> tomas@tuxteam.de writes:
> 
> > On Wed, Dec 02, 2009 at 07:03:02AM +0100, Andreas Politz wrote:

[...]

> > Mind you, I don't like it either, but any idea I had kills some aspect
> > of Simplicity we all appreciate in Emacs :-(
> >
> I am glad there isn't a third kind.  What about the idea of getting rid
> of them ?  Some ideas :
> 
> - a new family of regexp functions ([+]backwards compatibility)

I'm not sure this is needed. The functions themselves look fine to me.

> - a 2nd string syntax w/o escapes ([+]should not need new data-type)

Hm I was thinking about that too. But how would you represent e.g. a tab
in this new syntax?

> - a flag in the re to signal backslasheritis frailty
>   (\v in vim, [-]backwards compatibility)

I see (didn't know about this one).

> What kind of simplicity are you referring to ?

Well -- now, to express a regular expression we just need a normal
string. To do all this magic we'd first have to hook into the reader
before it gets hold of the string. Common Lisp has such a facility (you
can define a new reader syntax, which is very cool), but it pays some
price for this flexibility. Emacs has taken the conscious decision not
to go this route.

> >> - no short aliases for important constructs :
> >>   digits,symbol-constituents,newline,space
> >
> > Well, you always have those pesky [:stuff:] ones. They ain't so tidy,
> > but once you get used to them they are even more readable (and they
> > reduce the backslash density considerably).
> 
> That sounds pretty weak.  I would prefer \d over [[:digit:]] and [0-9] .

I miss that sometimes too :-)

> >> - no zero-width matches ; look(ahead|behind)
> >
> > Hm. To be fair, there are some, among others \b, \B, \<, \> (and the
> > funky \=, which matches at point). Yor are looking for a general zero
> > width match?
> 
> True. No, I was mostly thinking of look ahead/behind kind of context
> matching.  To be fair, I already saw a patch on emacs.dev, I believe,
> for this.  

Well, I see your points, but am torn. Simplicity, you know :-)

(Now having PEGs as an alternative to regexps would be quite exciting :)

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFLGgGwBcgs9XrR2kYRAgNyAJ0WnVxJc94YYyA2gozoGhmKt3mwfwCffApd
ERlCyw8tri/9Qa8BPJZO/8g=
=yyn6
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]