From: Marcin Borkowski <mbork@mbork.pl>
To: Tino Calancha <tino.calancha@gmail.com>
Cc: 26338@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
Subject: bug#26338: 26.0.50; Collect all matches for REGEXP in current buffer
Date: Tue, 04 Apr 2017 16:32:12 +0200 [thread overview]
Message-ID: <87pogsmefn.fsf@jane> (raw)
In-Reply-To: <87lgrheyvn.fsf@calancha-pc>
On 2017-04-04, at 03:37, Tino Calancha <tino.calancha@gmail.com> wrote:
> Juri Linkov <juri@linkov.net> writes:
>
>>>>> What do you think?
>>>>
>>>> But there is already the occur-collect feature implemented in occur-1
>>>> and occur-read-primary-args. Why would we need a separate command?
>>> Indeed i don't think we need a new command for this. I am thinking more
>>> in an standard function.
>>> Following:
>>> (occur "defun\\s +\\(\\S +\\)" "\\1")
>>>
>>> doesn't return the collected things. It writes the matches in *Occur*
>>> buffer. Then, if you want a list with the matches you must loop
>>> again inside *Occur* which is sub-optimal.
>>> For me, it has sense to have a `occur-collect' which just returns the
>>> list of matches.
>>> Then, we might use such function in the implementation of occur-1
>>> which could bring a cleaner implementation.
>>> We might get also the LIMIT argument for occur which might come
>>> in handy for multi-occur with lot of input buffers (just an idea).
>>
>> occur-collect is intended for interactive use. As for programmatic use,
>> Dmitry is right: a universal idiom is (while (re-search-forward ...)).
>> This is why e.g. the docstring of ‘replace-regexp’ recommends to use
>> an explicit loop like (while (re-search-forward ...) (replace-match ...))
> OK thanks. Let me ask you my last proposal before come back to my dark
> cave and start painting animals in the walls.
>
> Any interest in something like this?:
>
> (defmacro with-collect-matches (regexp &optional group &rest body)
> "Collect matches for REGEXP and eval BODY for each match.
> BODY is evaluated with `it' bound to the match.
> Optional GROUP if non-nil, then is the regexp group to save. Otherwise,
> save the whole match."
Sorry if this was said already, but why a macro and not a map-like
function?
Best,
--
Marcin Borkowski
next prev parent reply other threads:[~2017-04-04 14:32 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-02 12:41 bug#26338: 26.0.50; Collect all matches for REGEXP in current buffer Tino Calancha
2017-04-02 15:57 ` Dmitry Gutov
2017-04-03 3:58 ` Tino Calancha
2017-04-02 22:10 ` Juri Linkov
2017-04-03 4:01 ` Tino Calancha
2017-04-03 6:13 ` Tino Calancha
2017-04-03 23:35 ` Juri Linkov
2017-04-04 1:37 ` Tino Calancha
2017-04-04 2:20 ` Tino Calancha
2017-04-04 14:32 ` Marcin Borkowski [this message]
2017-04-05 11:58 ` Tino Calancha
2017-04-05 13:11 ` npostavs
2017-04-07 10:06 ` Tino Calancha
2017-04-07 14:40 ` Drew Adams
2017-04-08 4:45 ` Tino Calancha
2017-04-08 5:49 ` Drew Adams
2017-04-08 15:29 ` Tino Calancha
2017-04-08 15:42 ` Drew Adams
2017-04-08 11:46 ` Philipp Stephani
2017-04-08 13:42 ` Tino Calancha
2017-04-08 14:41 ` Philipp Stephani
2017-04-08 15:20 ` Tino Calancha
2017-04-22 19:42 ` Philipp Stephani
2017-04-08 15:38 ` npostavs
2017-04-22 19:36 ` Philipp Stephani
2017-04-05 22:03 ` Juri Linkov
2017-04-07 14:47 ` Tino Calancha
2017-04-07 15:28 ` Noam Postavsky
2017-04-07 15:54 ` Drew Adams
2017-04-08 13:49 ` Tino Calancha
2020-09-15 15:41 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pogsmefn.fsf@jane \
--to=mbork@mbork.pl \
--cc=26338@debbugs.gnu.org \
--cc=juri@linkov.net \
--cc=tino.calancha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).