summaryrefslogtreecommitdiff
path: root/devdocs/elisp/saving-match-data.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-08-14 22:58:58 -0500
committerCraig Jennings <c@cjennings.net>2025-08-14 22:58:58 -0500
commit82ba818ff456bcd6d56a06226e3f27e98fbb55c3 (patch)
tree158cfc17b2f644a10f063cb546752cfaae12c97f /devdocs/elisp/saving-match-data.html
parent9278ddd4ea1a8b1a4c1edaa8894516e3f48d245b (diff)
downloaddotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.tar.gz
dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.zip
removing all downloaded devdocs files
Diffstat (limited to 'devdocs/elisp/saving-match-data.html')
-rw-r--r--devdocs/elisp/saving-match-data.html19
1 files changed, 0 insertions, 19 deletions
diff --git a/devdocs/elisp/saving-match-data.html b/devdocs/elisp/saving-match-data.html
deleted file mode 100644
index 9aaa895b..00000000
--- a/devdocs/elisp/saving-match-data.html
+++ /dev/null
@@ -1,19 +0,0 @@
- <h4 class="subsection">Saving and Restoring the Match Data</h4> <p>When you call a function that may 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: </p> <div class="example"> <pre class="example">(re-search-forward "The \\(cat \\)")
- ⇒ 48
-(foo) ; <span class="roman"><code>foo</code> does more searching.</span>
-(match-end 0)
- ⇒ 61 ; <span class="roman">Unexpected result—not 48!</span>
-</pre>
-</div> <p>You can save and restore the match data with <code>save-match-data</code>: </p> <dl> <dt id="save-match-data">Macro: <strong>save-match-data</strong> <em>body…</em>
-</dt> <dd><p>This macro executes <var>body</var>, saving and restoring the match data around it. The return value is the value of the last form in <var>body</var>. </p></dd>
-</dl> <p>You could use <code>set-match-data</code> together with <code>match-data</code> to imitate the effect of the special form <code>save-match-data</code>. Here is how: </p> <div class="example"> <pre class="example">(let ((data (match-data)))
- (unwind-protect
- … ; <span class="roman">Ok to change the original match data.</span>
- (set-match-data data)))
-</pre>
-</div> <p>Emacs automatically saves and restores the match data when it runs process filter functions (see <a href="filter-functions">Filter Functions</a>) and process sentinels (see <a href="sentinels">Sentinels</a>). </p><div class="_attribution">
- <p class="_attribution-p">
- Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
- <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Saving-Match-Data.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Saving-Match-Data.html</a>
- </p>
-</div>