summaryrefslogtreecommitdiff
path: root/devdocs/elisp/substitution.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/substitution.html')
-rw-r--r--devdocs/elisp/substitution.html29
1 files changed, 29 insertions, 0 deletions
diff --git a/devdocs/elisp/substitution.html b/devdocs/elisp/substitution.html
new file mode 100644
index 00000000..4e0fd810
--- /dev/null
+++ b/devdocs/elisp/substitution.html
@@ -0,0 +1,29 @@
+ <h3 class="section">Substituting for a Character Code</h3> <p>The following functions replace characters within a specified region based on their character codes. </p> <dl> <dt id="subst-char-in-region">Function: <strong>subst-char-in-region</strong> <em>start end old-char new-char &amp;optional noundo</em>
+</dt> <dd>
+ <p>This function replaces all occurrences of the character <var>old-char</var> with the character <var>new-char</var> in the region of the current buffer defined by <var>start</var> and <var>end</var>. Both characters must have the same length of their multibyte form. </p> <p>If <var>noundo</var> is non-<code>nil</code>, then <code>subst-char-in-region</code> does not record the change for undo and does not mark the buffer as modified. This was useful for controlling the old selective display feature (see <a href="selective-display">Selective Display</a>). </p> <p><code>subst-char-in-region</code> does not move point and returns <code>nil</code>. </p> <div class="example"> <pre class="example">---------- Buffer: foo ----------
+This is the contents of the buffer before.
+---------- Buffer: foo ----------
+</pre>
+
+<pre class="example">(subst-char-in-region 1 20 ?i ?X)
+ ⇒ nil
+
+---------- Buffer: foo ----------
+ThXs Xs the contents of the buffer before.
+---------- Buffer: foo ----------
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="subst-char-in-string">Function: <strong>subst-char-in-string</strong> <em>fromchar tochar string &amp;optional inplace</em>
+</dt> <dd>
+ <p>This function replaces all occurrences of the character <var>fromchar</var> with <var>tochar</var> in <var>string</var>. By default, substitution occurs in a copy of <var>string</var>, but if the optional argument <var>inplace</var> is non-<code>nil</code>, the function modifies the <var>string</var> itself. In any case, the function returns the resulting string. </p>
+</dd>
+</dl> <dl> <dt id="translate-region">Command: <strong>translate-region</strong> <em>start end table</em>
+</dt> <dd>
+<p>This function applies a translation table to the characters in the buffer between positions <var>start</var> and <var>end</var>. </p> <p>The translation table <var>table</var> is a string or a char-table; <code>(aref <var>table</var> <var>ochar</var>)</code> gives the translated character corresponding to <var>ochar</var>. If <var>table</var> is a string, any characters with codes larger than the length of <var>table</var> are not altered by the translation. </p> <p>The return value of <code>translate-region</code> is the number of characters that were actually changed by the translation. This does not count characters that were mapped into themselves in the translation table. </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/Substitution.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Substitution.html</a>
+ </p>
+</div>