summaryrefslogtreecommitdiff
path: root/devdocs/elisp/entire-match-data.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/entire-match-data.html
new repository
Diffstat (limited to 'devdocs/elisp/entire-match-data.html')
-rw-r--r--devdocs/elisp/entire-match-data.html19
1 files changed, 19 insertions, 0 deletions
diff --git a/devdocs/elisp/entire-match-data.html b/devdocs/elisp/entire-match-data.html
new file mode 100644
index 00000000..faf76fdc
--- /dev/null
+++ b/devdocs/elisp/entire-match-data.html
@@ -0,0 +1,19 @@
+ <h4 class="subsection">Accessing the Entire Match Data</h4> <p>The functions <code>match-data</code> and <code>set-match-data</code> read or write the entire match data, all at once. </p> <dl> <dt id="match-data">Function: <strong>match-data</strong> <em>&amp;optional integers reuse reseat</em>
+</dt> <dd>
+<p>This function returns a list of positions (markers or integers) that record all the information on the text that the last search matched. Element zero is the position of the beginning of the match for the whole expression; element one is the position of the end of the match for the expression. The next two elements are the positions of the beginning and end of the match for the first subexpression, and so on. In general, element number 2<var>n</var> corresponds to <code>(match-beginning <var>n</var>)</code>; and element number 2<var>n</var> + 1 corresponds to <code>(match-end <var>n</var>)</code>. </p> <p>Normally all the elements are markers or <code>nil</code>, but if <var>integers</var> is non-<code>nil</code>, that means to use integers instead of markers. (In that case, the buffer itself is appended as an additional element at the end of the list, to facilitate complete restoration of the match data.) If the last match was done on a string with <code>string-match</code>, then integers are always used, since markers can’t point into a string. </p> <p>If <var>reuse</var> is non-<code>nil</code>, it should be a list. In that case, <code>match-data</code> stores the match data in <var>reuse</var>. That is, <var>reuse</var> is destructively modified. <var>reuse</var> does not need to have the right length. If it is not long enough to contain the match data, it is extended. If it is too long, the length of <var>reuse</var> stays the same, but the elements that were not used are set to <code>nil</code>. The purpose of this feature is to reduce the need for garbage collection. </p> <p>If <var>reseat</var> is non-<code>nil</code>, all markers on the <var>reuse</var> list are reseated to point to nowhere. </p> <p>As always, there must be no possibility of intervening searches between the call to a search function and the call to <code>match-data</code> that is intended to access the match data for that search. </p> <div class="example"> <pre class="example">(match-data)
+ ⇒ (#&lt;marker at 9 in foo&gt;
+ #&lt;marker at 17 in foo&gt;
+ #&lt;marker at 13 in foo&gt;
+ #&lt;marker at 17 in foo&gt;)
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="set-match-data">Function: <strong>set-match-data</strong> <em>match-list &amp;optional reseat</em>
+</dt> <dd>
+<p>This function sets the match data from the elements of <var>match-list</var>, which should be a list that was the value of a previous call to <code>match-data</code>. (More precisely, anything that has the same format will work.) </p> <p>If <var>match-list</var> refers to a buffer that doesn’t exist, you don’t get an error; that sets the match data in a meaningless but harmless way. </p> <p>If <var>reseat</var> is non-<code>nil</code>, all markers on the <var>match-list</var> list are reseated to point to nowhere. </p> <p><code>store-match-data</code> is a semi-obsolete alias for <code>set-match-data</code>. </p>
+</dd>
+</dl><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/Entire-Match-Data.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Entire-Match-Data.html</a>
+ </p>
+</div>