summaryrefslogtreecommitdiff
path: root/devdocs/elisp/insertion.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/insertion.html
new repository
Diffstat (limited to 'devdocs/elisp/insertion.html')
-rw-r--r--devdocs/elisp/insertion.html35
1 files changed, 35 insertions, 0 deletions
diff --git a/devdocs/elisp/insertion.html b/devdocs/elisp/insertion.html
new file mode 100644
index 00000000..4c526bb6
--- /dev/null
+++ b/devdocs/elisp/insertion.html
@@ -0,0 +1,35 @@
+ <h3 class="section">Inserting Text</h3> <p><em>Insertion</em> means adding new text to a buffer. The inserted text goes at point—between the character before point and the character after point. Some insertion functions leave point before the inserted text, while other functions leave it after. We call the former insertion <em>after point</em> and the latter insertion <em>before point</em>. </p> <p>Insertion moves markers located at positions after the insertion point, so that they stay with the surrounding text (see <a href="markers">Markers</a>). When a marker points at the place of insertion, insertion may or may not relocate the marker, depending on the marker’s insertion type (see <a href="marker-insertion-types">Marker Insertion Types</a>). Certain special functions such as <code>insert-before-markers</code> relocate all such markers to point after the inserted text, regardless of the markers’ insertion type. </p> <p>Insertion functions signal an error if the current buffer is read-only (see <a href="read-only-buffers">Read Only Buffers</a>) or if they insert within read-only text (see <a href="special-properties">Special Properties</a>). </p> <p>These functions copy text characters from strings and buffers along with their properties. The inserted characters have exactly the same properties as the characters they were copied from. By contrast, characters specified as separate arguments, not part of a string or buffer, inherit their text properties from the neighboring text. </p> <p>The insertion functions convert text from unibyte to multibyte in order to insert in a multibyte buffer, and vice versa—if the text comes from a string or from a buffer. However, they do not convert unibyte character codes 128 through 255 to multibyte characters, not even if the current buffer is a multibyte buffer. See <a href="converting-representations">Converting Representations</a>. </p> <dl> <dt id="insert">Function: <strong>insert</strong> <em>&amp;rest args</em>
+</dt> <dd><p>This function inserts the strings and/or characters <var>args</var> into the current buffer, at point, moving point forward. In other words, it inserts the text before point. An error is signaled unless all <var>args</var> are either strings or characters. The value is <code>nil</code>. </p></dd>
+</dl> <dl> <dt id="insert-before-markers">Function: <strong>insert-before-markers</strong> <em>&amp;rest args</em>
+</dt> <dd>
+<p>This function inserts the strings and/or characters <var>args</var> into the current buffer, at point, moving point forward. An error is signaled unless all <var>args</var> are either strings or characters. The value is <code>nil</code>. </p> <p>This function is unlike the other insertion functions in that it relocates markers initially pointing at the insertion point, to point after the inserted text. If an overlay begins at the insertion point, the inserted text falls outside the overlay; if a nonempty overlay ends at the insertion point, the inserted text falls inside that overlay. </p>
+</dd>
+</dl> <dl> <dt id="insert-char">Command: <strong>insert-char</strong> <em>character &amp;optional count inherit</em>
+</dt> <dd>
+<p>This command inserts <var>count</var> instances of <var>character</var> into the current buffer before point. The argument <var>count</var> must be an integer, and <var>character</var> must be a character. </p> <p>If called interactively, this command prompts for <var>character</var> using its Unicode name or its code point. See <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Inserting-Text.html#Inserting-Text">Inserting Text</a> in <cite>The GNU Emacs Manual</cite>. </p> <p>This function does not convert unibyte character codes 128 through 255 to multibyte characters, not even if the current buffer is a multibyte buffer. See <a href="converting-representations">Converting Representations</a>. </p> <p>If <var>inherit</var> is non-<code>nil</code>, the inserted characters inherit sticky text properties from the two characters before and after the insertion point. See <a href="sticky-properties">Sticky Properties</a>. </p>
+</dd>
+</dl> <dl> <dt id="insert-buffer-substring">Function: <strong>insert-buffer-substring</strong> <em>from-buffer-or-name &amp;optional start end</em>
+</dt> <dd>
+<p>This function inserts a portion of buffer <var>from-buffer-or-name</var> into the current buffer before point. The text inserted is the region between <var>start</var> (inclusive) and <var>end</var> (exclusive). (These arguments default to the beginning and end of the accessible portion of that buffer.) This function returns <code>nil</code>. </p> <p>In this example, the form is executed with buffer ‘<samp>bar</samp>’ as the current buffer. We assume that buffer ‘<samp>bar</samp>’ is initially empty. </p> <div class="example"> <pre class="example">---------- Buffer: foo ----------
+We hold these truths to be self-evident, that all
+---------- Buffer: foo ----------
+</pre>
+
+<pre class="example">(insert-buffer-substring "foo" 1 20)
+ ⇒ nil
+
+---------- Buffer: bar ----------
+We hold these truth∗
+---------- Buffer: bar ----------
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="insert-buffer-substring-no-properties">Function: <strong>insert-buffer-substring-no-properties</strong> <em>from-buffer-or-name &amp;optional start end</em>
+</dt> <dd><p>This is like <code>insert-buffer-substring</code> except that it does not copy any text properties. </p></dd>
+</dl> <dl> <dt id="insert-into-buffer">Function: <strong>insert-into-buffer</strong> <em>to-buffer &amp;optional start end</em>
+</dt> <dd><p>This is like <code>insert-buffer-substring</code>, but works in the opposite direction: The text is copied from the current buffer into <var>to-buffer</var>. The block of text is copied to the current point in <var>to-buffer</var>, and point (in that buffer) is advanced to after the end of the copied text. Is <code>start</code>/<code>end</code> is <code>nil</code>, the entire text in the current buffer is copied over. </p></dd>
+</dl> <p>See <a href="sticky-properties">Sticky Properties</a>, for other insertion functions that inherit text properties from the nearby text in addition to inserting it. Whitespace inserted by indentation functions also inherits text properties. </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/Insertion.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Insertion.html</a>
+ </p>
+</div>