summaryrefslogtreecommitdiff
path: root/devdocs/elisp/sticky-properties.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/sticky-properties.html
new repository
Diffstat (limited to 'devdocs/elisp/sticky-properties.html')
-rw-r--r--devdocs/elisp/sticky-properties.html14
1 files changed, 14 insertions, 0 deletions
diff --git a/devdocs/elisp/sticky-properties.html b/devdocs/elisp/sticky-properties.html
new file mode 100644
index 00000000..1f6f658a
--- /dev/null
+++ b/devdocs/elisp/sticky-properties.html
@@ -0,0 +1,14 @@
+ <h4 class="subsection">Stickiness of Text Properties</h4> <p>Self-inserting characters, the ones that get inserted into a buffer when the user types them (see <a href="commands-for-insertion">Commands for Insertion</a>), normally take on the same properties as the preceding character. This is called <em>inheritance</em> of properties. </p> <p>By contrast, a Lisp program can do insertion with inheritance or without, depending on the choice of insertion primitive. The ordinary text insertion functions, such as <code>insert</code>, do not inherit any properties. They insert text with precisely the properties of the string being inserted, and no others. This is correct for programs that copy text from one context to another—for example, into or out of the kill ring. To insert with inheritance, use the special primitives described in this section. Self-inserting characters inherit properties because they work using these primitives. </p> <p>When you do insertion with inheritance, <em>which</em> properties are inherited, and from where, depends on which properties are <em>sticky</em>. Insertion after a character inherits those of its properties that are <em>rear-sticky</em>. Insertion before a character inherits those of its properties that are <em>front-sticky</em>. When both sides offer different sticky values for the same property, the previous character’s value takes precedence. </p> <p>By default, a text property is rear-sticky but not front-sticky; thus, the default is to inherit all the properties of the preceding character, and nothing from the following character. </p> <p>You can control the stickiness of various text properties with two specific text properties, <code>front-sticky</code> and <code>rear-nonsticky</code>, and with the variable <code>text-property-default-nonsticky</code>. You can use the variable to specify a different default for a given property. You can use those two text properties to make any specific properties sticky or nonsticky in any particular part of the text. </p> <p>If a character’s <code>front-sticky</code> property is <code>t</code>, then all its properties are front-sticky. If the <code>front-sticky</code> property is a list, then the sticky properties of the character are those whose names are in the list. For example, if a character has a <code>front-sticky</code> property whose value is <code>(face read-only)</code>, then insertion before the character can inherit its <code>face</code> property and its <code>read-only</code> property, but no others. </p> <p>The <code>rear-nonsticky</code> property works the opposite way. Most properties are rear-sticky by default, so the <code>rear-nonsticky</code> property says which properties are <em>not</em> rear-sticky. If a character’s <code>rear-nonsticky</code> property is <code>t</code>, then none of its properties are rear-sticky. If the <code>rear-nonsticky</code> property is a list, properties are rear-sticky <em>unless</em> their names are in the list. </p> <dl> <dt id="text-property-default-nonsticky">Variable: <strong>text-property-default-nonsticky</strong>
+</dt> <dd>
+<p>This variable holds an alist which defines the default rear-stickiness of various text properties. Each element has the form <code>(<var>property</var> . <var>nonstickiness</var>)</code>, and it defines the stickiness of a particular text property, <var>property</var>. </p> <p>If <var>nonstickiness</var> is non-<code>nil</code>, this means that the property <var>property</var> is rear-nonsticky by default. Since all properties are front-nonsticky by default, this makes <var>property</var> nonsticky in both directions by default. </p> <p>The text properties <code>front-sticky</code> and <code>rear-nonsticky</code>, when used, take precedence over the default <var>nonstickiness</var> specified in <code>text-property-default-nonsticky</code>. </p>
+</dd>
+</dl> <p>Here are the functions that insert text with inheritance of properties: </p> <dl> <dt id="insert-and-inherit">Function: <strong>insert-and-inherit</strong> <em>&amp;rest strings</em>
+</dt> <dd><p>Insert the strings <var>strings</var>, just like the function <code>insert</code>, but inherit any sticky properties from the adjoining text. </p></dd>
+</dl> <dl> <dt id="insert-before-markers-and-inherit">Function: <strong>insert-before-markers-and-inherit</strong> <em>&amp;rest strings</em>
+</dt> <dd><p>Insert the strings <var>strings</var>, just like the function <code>insert-before-markers</code>, but inherit any sticky properties from the adjoining text. </p></dd>
+</dl> <p>See <a href="insertion">Insertion</a>, for the ordinary insertion functions which do not inherit. </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/Sticky-Properties.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Sticky-Properties.html</a>
+ </p>
+</div>