[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Saving match data
From: |
Michael Heerdegen |
Subject: |
Re: Saving match data |
Date: |
Sat, 08 Oct 2016 06:02:44 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
Eli Zaretskii <address@hidden> writes:
> Maybe I misunderstand the proposal, because it sounds very similar to
> what we have. Could you perhaps show an example using the current and
> the proposed technique, so that the differences are clear?
Well, what currently looks like (using some fantasy function names)
#+begin_src emacs-lisp
(progn
(search-forward "test")
(save-match-data
(do-this)
(maybe-change-match-data-here)
(do-that))
(use-the-match-data))
#+end_src
could become something like
#+begin_src emacs-lisp
(with-match-data data
(search-forward "test")
(do-this)
(maybe-change-match-data-here)
(do-that)
(use-match-data data
(use-the-match-data)))
#+end_src
We don't have multiple values in Elisp. So, `with-match-data' could be
a macro that binds a specified variable in first position to the match
data present after (normally) evaluating the expression in the second
position. `use-match-data' would be another macro that would change the
match data in its scope to the evaluation result of the sexp in the
first position.
Honestly, I don't really want to propose to change things, if either in
this direction, or at all... as long as we don't invest too much time to
consolidate what we have now (like ensuring tons of function to not
change match data).
Regards,
Michael.
- Re: Saving match data,
Michael Heerdegen <=