From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.bugs Subject: bug#26338: 26.0.50; Collect all matches for REGEXP in current buffer Date: Tue, 04 Apr 2017 16:32:12 +0200 Message-ID: <87pogsmefn.fsf@jane> References: <8737dr6kxx.fsf@calancha-pc> <87h926cvgl.fsf@localhost> <87k272ow7g.fsf@calancha-pc> <87fuhpcbem.fsf@localhost> <87lgrheyvn.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1491316399 29431 195.159.176.226 (4 Apr 2017 14:33:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Apr 2017 14:33:19 +0000 (UTC) User-Agent: mu4e 0.9.19; emacs 26.0.50 Cc: 26338@debbugs.gnu.org, Juri Linkov To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 04 16:33:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvPWB-0006oe-Ck for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Apr 2017 16:33:11 +0200 Original-Received: from localhost ([::1]:36022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvPWH-0001Wx-AX for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Apr 2017 10:33:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvPW8-0001UZ-FN for bug-gnu-emacs@gnu.org; Tue, 04 Apr 2017 10:33:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvPW2-0006UB-Of for bug-gnu-emacs@gnu.org; Tue, 04 Apr 2017 10:33:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34351) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cvPW2-0006Ts-L4 for bug-gnu-emacs@gnu.org; Tue, 04 Apr 2017 10:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cvPW1-000609-RD for bug-gnu-emacs@gnu.org; Tue, 04 Apr 2017 10:33:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Marcin Borkowski Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Apr 2017 14:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26338 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 26338-submit@debbugs.gnu.org id=B26338.149131634723021 (code B ref 26338); Tue, 04 Apr 2017 14:33:01 +0000 Original-Received: (at 26338) by debbugs.gnu.org; 4 Apr 2017 14:32:27 +0000 Original-Received: from localhost ([127.0.0.1]:60783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvPVS-0005zF-QY for submit@debbugs.gnu.org; Tue, 04 Apr 2017 10:32:27 -0400 Original-Received: from mail.mojserwer.eu ([195.110.48.8]:42814) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvPVQ-0005z6-57 for 26338@debbugs.gnu.org; Tue, 04 Apr 2017 10:32:24 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 05AD1E6BAA; Tue, 4 Apr 2017 16:32:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2LdV1jtsMvKt; Tue, 4 Apr 2017 16:32:19 +0200 (CEST) Original-Received: from localhost (apn-31-0-23-27.dynamic.gprs.plus.pl [31.0.23.27]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 99DFEE6A30; Tue, 4 Apr 2017 16:32:18 +0200 (CEST) In-reply-to: <87lgrheyvn.fsf@calancha-pc> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131275 Archived-At: On 2017-04-04, at 03:37, Tino Calancha wrote: > Juri Linkov 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