summaryrefslogtreecommitdiff
path: root/devdocs/elisp/global-variables.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/global-variables.html')
-rw-r--r--devdocs/elisp/global-variables.html19
1 files changed, 19 insertions, 0 deletions
diff --git a/devdocs/elisp/global-variables.html b/devdocs/elisp/global-variables.html
new file mode 100644
index 00000000..69a03e86
--- /dev/null
+++ b/devdocs/elisp/global-variables.html
@@ -0,0 +1,19 @@
+ <h3 class="section">Global Variables</h3> <p>The simplest way to use a variable is <em>globally</em>. This means that the variable has just one value at a time, and this value is in effect (at least for the moment) throughout the Lisp system. The value remains in effect until you specify a new one. When a new value replaces the old one, no trace of the old value remains in the variable. </p> <p>You specify a value for a symbol with <code>setq</code>. For example, </p> <div class="example"> <pre class="example">(setq x '(a b))
+</pre>
+</div> <p>gives the variable <code>x</code> the value <code>(a b)</code>. Note that <code>setq</code> is a special form (see <a href="special-forms">Special Forms</a>); it does not evaluate its first argument, the name of the variable, but it does evaluate the second argument, the new value. </p> <p>Once the variable has a value, you can refer to it by using the symbol itself as an expression. Thus, </p> <div class="example"> <pre class="example">x ⇒ (a b)
+</pre>
+</div> <p>assuming the <code>setq</code> form shown above has already been executed. </p> <p>If you do set the same variable again, the new value replaces the old one: </p> <div class="example"> <pre class="example">x
+ ⇒ (a b)
+</pre>
+<pre class="example">(setq x 4)
+ ⇒ 4
+</pre>
+<pre class="example">x
+ ⇒ 4
+</pre>
+</div><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/Global-Variables.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Global-Variables.html</a>
+ </p>
+</div>