From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#26338: 26.0.50; Collect all matches for REGEXP in current buffer Date: Tue, 04 Apr 2017 10:37:48 +0900 Message-ID: <87lgrheyvn.fsf@calancha-pc> References: <8737dr6kxx.fsf@calancha-pc> <87h926cvgl.fsf@localhost> <87k272ow7g.fsf@calancha-pc> <87fuhpcbem.fsf@localhost> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1491269954 28180 195.159.176.226 (4 Apr 2017 01:39:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Apr 2017 01:39:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 26338@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 04 03:39:09 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 1cvDR5-0006OT-ON for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Apr 2017 03:39:07 +0200 Original-Received: from localhost ([::1]:33596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvDRA-00036U-01 for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Apr 2017 21:39:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvDR3-00036F-H4 for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:39:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvDR0-0001dg-E7 for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:39:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33252) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cvDR0-0001db-AQ for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cvDR0-0000Ui-1y for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Apr 2017 01:39: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.14912698821822 (code B ref 26338); Tue, 04 Apr 2017 01:39:01 +0000 Original-Received: (at 26338) by debbugs.gnu.org; 4 Apr 2017 01:38:02 +0000 Original-Received: from localhost ([127.0.0.1]:59682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvDQ1-0000TK-TD for submit@debbugs.gnu.org; Mon, 03 Apr 2017 21:38:02 -0400 Original-Received: from mail-pg0-f41.google.com ([74.125.83.41]:34670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvDPy-0000SU-KG for 26338@debbugs.gnu.org; Mon, 03 Apr 2017 21:38:00 -0400 Original-Received: by mail-pg0-f41.google.com with SMTP id 21so137040967pgg.1 for <26338@debbugs.gnu.org>; Mon, 03 Apr 2017 18:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=bzGvWZ4OtyTdrCUtwnUlSTI8PwTyKKtptHXLvD1+ngo=; b=W0u3pbtO30d0SHNwBXt5TNBUbqoAD8gs8xMQA0zh305ZBHFEtWtqsxur/XcTbf8hbY 9DnJYQFoH/zS0QwjHNA0PuIrB08uReodQaEjSYkubAu/wTMnMHCi2GbYwFl7IDco5beQ PsjluViGlt0JOL94SMvKhh7bH6dy+Yex3bZ+CLIdY+1B/usx3MsS0ipPhWoXBw0tNOCY oaoXdbDEBDPhFBNL9IBAbiZQljAw7PV92Fg4SxTeaqQBhYV1wLwRrK2TIQvokeU3cvMm W8/4XOKKaSwzggXqg1tUzJOjb0AbwxtkquCCXHPb562oOhKP4Bwi0uML4R01AlWKNg9o 4h6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=bzGvWZ4OtyTdrCUtwnUlSTI8PwTyKKtptHXLvD1+ngo=; b=DOIvyYpQPEg73svzqRYiFirs4c7V7B4E7eZ6m+bvuA+jqrRftn8gJiwj/Frf5TLwYa 10dcUOomr/9Zc1IuGF5xrBcTBeGgobo5SJHfWScIhqwEq2ojHJjWWu6y8zV5cbJGYL04 xM/YmuSKKwioveU5ZtPeZEa50ig7VDRo+wq0Qv+1/a8f/+C1dnD/PP/91bJqFm8tUE+1 OYn0h0IytY+GvodD0BEHm3O9j2biRp+3xxg66PFfdNdXI89DqO8LEIQr/JrUZKEGEHvy YyyUhQmW/JWnspjnDcko/4OK6o7AWJWc4XesGzPa2Ubv/6B4eccAStDRlC1RzXvXtJ8T I5kw== X-Gm-Message-State: AFeK/H3BdZHiDSdRiUZ4kx9ob5VtwdubG45xr5VC2Yp/IiVhXumJIIZJ1OLxkYEMLwwYnA== X-Received: by 10.84.229.13 with SMTP id b13mr25291851plk.72.1491269872711; Mon, 03 Apr 2017 18:37:52 -0700 (PDT) Original-Received: from calancha-pc (234.204.100.220.dy.bbexcite.jp. [220.100.204.234]) by smtp.gmail.com with ESMTPSA id s11sm28101238pgc.61.2017.04.03.18.37.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Apr 2017 18:37:52 -0700 (PDT) In-Reply-To: <87fuhpcbem.fsf@localhost> (Juri Linkov's message of "Tue, 04 Apr 2017 02:35:29 +0300") 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:131258 Archived-At: 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 =E2=80=98replace-regexp=E2=80=99 recomm= ends 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."