emacs-devel
[Top][All Lists]
Advanced

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

Re: Add some aliases for re-related functions


From: Dmitry Gutov
Subject: Re: Add some aliases for re-related functions
Date: Sun, 3 May 2020 02:13:42 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 03.05.2020 01:49, Stefan Monnier wrote:
[ I'm trying to use "search" and "match" in the way it's used in
    traditional regexp libraries.  ]
Guess I'm unfamiliar with said libraries. I'd suggest re-looking-at and
re-looking-back (or whatever, like, don't create an alias for the last
one if we don't want to).

Most of the literature on regular expressions concentrates on the
problem of finding whether a given string matches a given regexp, where
"matching" here means that the regexp matches the whole string.

Right. Buffers are an Emacs specific.

Think of it as the case where the regexp starts with \` and ends with \'

Then there's the relaxation of "finding the longest match" (what we
call `looking-at`) and then "finding the leftmost longest match" (what
we call `string-match`).

looking-at being a special case of re-search-forward, I take?

Those two have traditionally be named `re_match` and `re_search`
respectively in C libraries (as can be seen in `src/regexp-emacs.c`).

Yes, ok. But we also need names to distinguish that things happen in a buffer. So far we've used 'search' for those.

Using the term 'search' for matching in strings might be a significant change, given existing expectations.

PS: BTW, `looking-back` doesn't do a "match" of the "longest match that
ends at point" but a "search" for the "rightmost longest match that ends
at point" since it uses `re-search-backward` internally.

It's a weird function, I agree. Though it's proved to be a handy one.



reply via email to

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