GNU bug report logs -
#26338
26.0.50; Collect all matches for REGEXP in current buffer
Previous Next
Reported by: Tino Calancha <tino.calancha <at> gmail.com>
Date: Sun, 2 Apr 2017 12:42:01 UTC
Severity: wishlist
Tags: wontfix
Found in version 26.0.50
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On Fri, 7 Apr 2017, Drew Adams wrote:
>>> Or an addition to cl-loop that would allow doing something like
>>>
>>> (cl-loop for m being the matches of "foo\\|bar"
>>> do ...)
>>>
>>> Then you could easily 'collect m' to get the list of matches if you want
>>> that.
>>
>> Your proposals looks nice to me ;-)
>
> (Caveat: I have not been following this thread.)
>
> I think that `cl-loop' should be as close to Common Lisp `loop'
> as we can reasonably make it. We should _not_ be adding other
> features to it or changing its behavior away from what it is
> supposedly emulating.
>
> If you want, create a _different_ macro that is Emacs-specific,
> with whatever behavior you want. Call it whatever you want
> that will not be confused with Common Lisp emulation.
>
> Please keep `cl-' for Common Lisp emulation. We've already
> seen more than enough tampering with this - people adding
> their favorite thing to the `cl-' namespace. Not good.
Drew, i respect your opinion; but so far the change
would just extend `cl-loop' which as you noticed has being already
extended before.
For instance, we have:
cl-loop for x being the overlays/buffers ...
Don't see a problem to have those things. We already point out in the
manual that these are Emacs specific things, so nobody should be fooled
with that. As far as we cover all CL clauses, what problem could be in
having a few more?
I find interesting be able to do things like the following:
--8<-----------------------------cut here---------------start------------->8---
(require 'find-lisp)
(let ((op "defun")
(dir (expand-file-name "lisp" source-directory)))
(setq funcs
(cl-loop for f in (find-lisp-find-files dir "\.el\\'") nconc
(with-temp-buffer
(insert-file-contents-literally f)
(let ((regexp (format "^(%s \\(\\S +\\)" op)))
(cl-loop for x the matches of regexp using '(group 1) collect x)))))
(length funcs))
=> 38898 ; op: defun
=> 1256 ; op: defmacro
=> 1542 ; op: defsubst
--8<-----------------------------cut here---------------end--------------->8---
This bug report was last modified 4 years and 250 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.