Subject: Re: bug#26338: 26.0.50; Collect all matches for REGEXP in current buffer

From: Dmitry Gutov <[email-masked]>
Date: Sun, 2 Apr 2017 18:57:02 +0300

On 02.04.2017 15:41, Tino Calancha wrote:

> we have `count-matches' in replace.el, which returns the
> number of matches of a regexp.  Why not to have an standard
> function `collect-matches' as well?
> 
> I know `xref-collect-matches' but it uses grep program: some users might
> not have grep installed, or they may prefer to use Emacs regexps.
> 
> I've being using for a while something similar than the patch below.
> Probably it doesn't need to be a command, just a normal function.
> 
> What do you think?
When used interactively, isn't M-x occur doing something like this?

And for Elisp programs, (while (re-search-forward ...)) is usually 
sufficient. That's a three-liner at worst.

And I've never had a need to limit the number of matches, personally.