[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving match data

From: Lars Ingebrigtsen
Subject: Re: Saving match data
Date: Wed, 28 Sep 2016 22:58:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> You would bind the match data to a variable directly when it is
> produced, and refer to it later by that variable name.

This is how it's done in most languages.

To be explicit in an Emacs context: if you wanted to double the number
in all instances of a<number>, it could look like:

(while (setq match (new-re-search-forward "a\\([0-9]+\\)" nil t))
  (insert (match match 1)))

It would be nice and clean and all, but the current global state thing
we have now is rarely any problem in practice.  You just have to learn
to do no non-trivial operations between the match and where you use the
match data.

(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

[Prev in Thread] Current Thread [Next in Thread]