[Top][All Lists]

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

Re: Embedded modifiers in the regex engine

From: Dima Kogan
Subject: Re: Embedded modifiers in the regex engine
Date: Fri, 22 Apr 2016 22:17:08 -0600
User-agent: mu4e 0.9.17; emacs

Dima Kogan <address@hidden> writes:

> Eli Zaretskii <address@hidden> writes:
>>> > What's wrong with the existing one?
>>> Maybe nothing. I'd like to add a feature, but if there are plans to
>>> abandon the current implementation, then I want to add my feature to
>>> whatever the new implementation is.
>> AFAIK, no one works on replacing the current implementation.  So we
>> should talk about the changes first, and worry about replacing the
>> current code later.
> OK. I'll go back to look at my earlier work to add the feature to the
> current implementation.

Sorry for the delay. An initial implementation of the case-fold embedded
modifiers lives at


That tree contains the implementation and the tests. This is not
intended to be a final implementation, but should be sufficient to get a
comment from the list. If this looks like something we're not going to
want to merge, I'd like to know before I put more work into it. Most
things should work as one would expect. Some fancier regexen probably do
not work yet; more tests should be written to test more cases. Maybe the
tests from the perl project should be imported into the suite in
addition to the glibc ones.

Clearly, this is not a small patch, but the test suite should hopefully
serve as some assurance that this doesn't break things (too badly).

The new code adds two patterns the regex engine understands:

   \(i\)   to turn on case-fold
   \(-i\)  to turn off case-fold

These are active until another such pattern is encountered, or until the
end of a () group. This is exactly how these work in perl. Before any of
these is encountered, the value of `case-fold-search' is used, so the
previous behavior should be preserved.

In the code, most functions previously accepted a `translate' argument
that was NULL to indicate that no case-fold is desired. This argument is
non-NULL in the new code, with an additional case-fold arg to indicate
the initial state.

The larger goal here, in my mind, is to add modifiers for all the
various switches that we have in isearch: lax-whitespace, char-fold,
symbol-search, word-search, etc. I can imagine this being useful for
various things, in particular making search histories work nicer, making
hi-lock simpler and so on.


reply via email to

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