emacs-devel
[Top][All Lists]
Advanced

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

Re: Make \< and \> match symbol boundaries


From: Miles Bader
Subject: Re: Make \< and \> match symbol boundaries
Date: 30 Oct 2001 10:18:11 +0900

Richard Stallman <address@hidden> writes:
>     Here's another idea: generalize the existing regexps \b, \B, etc. to
>     support arbitrary classes and syntaxes, not just word syntax.  For
>     example, to generalize \b we could add the following regexps:
...
>     If we take this approach, then \-<s_ and \->s_ would have the desired
>     interpretation of matching symbol boundaries.

I don't think this is true -- one of the more annoying things about
syntax tables is the symbol syntax (_) only applies to those characters
that don't have word syntax, so there's no one syntax that captures
both.

So the the suggested \-<s_ would only match the beginning of `_foo', not
`foo'.

This is why I'm a bit leary of any new syntax that only accepts a single
syntax class, as it fails for such a common case.

How about adding the ability to use `syntax sets'?  Then the above new
syntax could be made to do the right thing.  For instance, anyplace in a
regexp that accepts a syntax class character could be extended to also
support a set of syntax class characters, surrounded by `[' and ']'.

Then one could use \s[w_] to match a word-or-symbol character, and 
using Dave's new syntax, \-<s[w_] would be equivalent to \_< .

-Miles
-- 
I'd rather be consing.



reply via email to

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