summaryrefslogtreecommitdiff
path: root/devdocs/elisp/symbol-plists.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/symbol-plists.html')
-rw-r--r--devdocs/elisp/symbol-plists.html40
1 files changed, 40 insertions, 0 deletions
diff --git a/devdocs/elisp/symbol-plists.html b/devdocs/elisp/symbol-plists.html
new file mode 100644
index 00000000..e0cfb30b
--- /dev/null
+++ b/devdocs/elisp/symbol-plists.html
@@ -0,0 +1,40 @@
+ <h4 class="subsection">Accessing Symbol Properties</h4> <p>The following functions can be used to access symbol properties. </p> <dl> <dt id="get">Function: <strong>get</strong> <em>symbol property</em>
+</dt> <dd>
+<p>This function returns the value of the property named <var>property</var> in <var>symbol</var>’s property list. If there is no such property, it returns <code>nil</code>. Thus, there is no distinction between a value of <code>nil</code> and the absence of the property. </p> <p>The name <var>property</var> is compared with the existing property names using <code>eq</code>, so any object is a legitimate property. </p> <p>See <code>put</code> for an example. </p>
+</dd>
+</dl> <dl> <dt id="put">Function: <strong>put</strong> <em>symbol property value</em>
+</dt> <dd>
+<p>This function puts <var>value</var> onto <var>symbol</var>’s property list under the property name <var>property</var>, replacing any previous property value. The <code>put</code> function returns <var>value</var>. </p> <div class="example"> <pre class="example">(put 'fly 'verb 'transitive)
+ ⇒'transitive
+(put 'fly 'noun '(a buzzing little bug))
+ ⇒ (a buzzing little bug)
+(get 'fly 'verb)
+ ⇒ transitive
+(symbol-plist 'fly)
+ ⇒ (verb transitive noun (a buzzing little bug))
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="symbol-plist">Function: <strong>symbol-plist</strong> <em>symbol</em>
+</dt> <dd><p>This function returns the property list of <var>symbol</var>. </p></dd>
+</dl> <dl> <dt id="setplist">Function: <strong>setplist</strong> <em>symbol plist</em>
+</dt> <dd>
+<p>This function sets <var>symbol</var>’s property list to <var>plist</var>. Normally, <var>plist</var> should be a well-formed property list, but this is not enforced. The return value is <var>plist</var>. </p> <div class="example"> <pre class="example">(setplist 'foo '(a 1 b (2 3) c nil))
+ ⇒ (a 1 b (2 3) c nil)
+(symbol-plist 'foo)
+ ⇒ (a 1 b (2 3) c nil)
+</pre>
+</div> <p>For symbols in special obarrays, which are not used for ordinary purposes, it may make sense to use the property list cell in a nonstandard fashion; in fact, the abbrev mechanism does so (see <a href="abbrevs">Abbrevs</a>). </p> <p>You could define <code>put</code> in terms of <code>setplist</code> and <code>plist-put</code>, as follows: </p> <div class="example"> <pre class="example">(defun put (symbol prop value)
+ (setplist symbol
+ (plist-put (symbol-plist symbol) prop value)))
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="function-get">Function: <strong>function-get</strong> <em>symbol property &amp;optional autoload</em>
+</dt> <dd><p>This function is identical to <code>get</code>, except that if <var>symbol</var> is the name of a function alias, it looks in the property list of the symbol naming the actual function. See <a href="defining-functions">Defining Functions</a>. If the optional argument <var>autoload</var> is non-<code>nil</code>, and <var>symbol</var> is auto-loaded, this function will try to autoload it, since autoloading might set <var>property</var> of <var>symbol</var>. If <var>autoload</var> is the symbol <code>macro</code>, only try autoloading if <var>symbol</var> is an auto-loaded macro. </p></dd>
+</dl> <dl> <dt id="function-put">Function: <strong>function-put</strong> <em>function property value</em>
+</dt> <dd><p>This function sets <var>property</var> of <var>function</var> to <var>value</var>. <var>function</var> should be a symbol. This function is preferred to calling <code>put</code> for setting properties of a function, because it will allow us some day to implement remapping of old properties to new ones. </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/Symbol-Plists.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Symbol-Plists.html</a>
+ </p>
+</div>