diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/global-variables.html | |
new repository
Diffstat (limited to 'devdocs/elisp/global-variables.html')
| -rw-r--r-- | devdocs/elisp/global-variables.html | 19 |
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 © 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> |
