[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: re-make-list
From: |
tomas |
Subject: |
Re: re-make-list |
Date: |
Mon, 10 Feb 2020 07:58:20 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Mon, Feb 10, 2020 at 06:11:25AM +0100, Emanuel Berg via Users list for the
GNU Emacs text editor wrote:
> Make a list of regexp matches... perhaps
> already in Emacs/ELPA/Joe Hacker's stash/etc?
>
> Improvements AND comment look like this:
>
> ;; improvement
>
> ha ha :)
>
> ;; this file: https://dataswamp.org/~incal/emacs-init/re-make-list.el
>
> (defun re-make-list (re &optional start stop)
> (interactive
> (if (use-region-p)
> (list (region-beginning) (region-end))
> (list (point-min) (point-max)) ))
> (save-excursion
> (let ((matches ()))
> (goto-char start)
> (while (re-search-forward re stop t)
> (push (match-string-no-properties 0) matches) )
> matches) ))
[...]
If you don't mind the matches being returned in reverse order, that's
fine. Otherwise you might consider returning (reverse matches).
In your case, since you build a fresh list which nobody else sees,
you might get away returning (nreverse matches) without the Functional
Gods frowning at you ;-)
Cheers
-- t
signature.asc
Description: Digital signature
- re-make-list, Emanuel Berg, 2020/02/10
- Re: re-make-list,
tomas <=
- Re: re-make-list, Emanuel Berg, 2020/02/10
- Re: re-make-list, tomas, 2020/02/10
- Re: re-make-list, Emanuel Berg, 2020/02/10
- Re: re-make-list, tomas, 2020/02/10
- Re: re-make-list, Stefan Monnier, 2020/02/10
- Re: re-make-list, tomas, 2020/02/10
- Re: re-make-list, Emanuel Berg, 2020/02/10
- Re: re-make-list, Emanuel Berg, 2020/02/10
- Re: re-make-list, Emanuel Berg, 2020/02/10
- Re: re-make-list, Stefan Monnier, 2020/02/11