[ < ] | [ > ] | [ << ] | [Plus haut] | [ >> ] | [Top] | [Table des matières] | [Index] | [ ? ] |
When you call a function that may do a search, you may need to save and restore the match data around that call, if you want to preserve the match data from an earlier search for later use. Here is an example that shows the problem that arises if you fail to save the match data:
(re-search-forward "The \\(cat \\)")
⇒ 48
(foo) ; Perhaps |
You can save and restore the match data with save-match-data
:
This macro executes body, saving and restoring the match data around it. The return value is the value of the last form in body.
You could use set-match-data
together with match-data
to
imitate the effect of the special form save-match-data
. Here is how:
(let ((data (match-data)))
(unwind-protect
… ; Ok to change the original match data.
(set-match-data data)))
|
Emacs automatically saves and restores the match data when it runs process filter functions (voir la section Process Filter Functions) and process sentinels (voir la section Sentinels: Detecting Process Status Changes).
Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.