summaryrefslogtreecommitdiff
path: root/devdocs/elisp/definitions.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/definitions.html')
-rw-r--r--devdocs/elisp/definitions.html6
1 files changed, 6 insertions, 0 deletions
diff --git a/devdocs/elisp/definitions.html b/devdocs/elisp/definitions.html
new file mode 100644
index 00000000..781b7552
--- /dev/null
+++ b/devdocs/elisp/definitions.html
@@ -0,0 +1,6 @@
+ <h3 class="section">Defining Symbols</h3> <p>A <em>definition</em> is a special kind of Lisp expression that announces your intention to use a symbol in a particular way. It typically specifies a value or meaning for the symbol for one kind of use, plus documentation for its meaning when used in this way. Thus, when you define a symbol as a variable, you can supply an initial value for the variable, plus documentation for the variable. </p> <p><code>defvar</code> and <code>defconst</code> are special forms that define a symbol as a <em>global variable</em>—a variable that can be accessed at any point in a Lisp program. See <a href="variables">Variables</a>, for details about variables. To define a customizable variable, use the <code>defcustom</code> macro, which also calls <code>defvar</code> as a subroutine (see <a href="customization">Customization</a>). </p> <p>In principle, you can assign a variable value to any symbol with <code>setq</code>, whether or not it has first been defined as a variable. However, you ought to write a variable definition for each global variable that you want to use; otherwise, your Lisp program may not act correctly if it is evaluated with lexical scoping enabled (see <a href="variable-scoping">Variable Scoping</a>). </p> <p><code>defun</code> defines a symbol as a function, creating a lambda expression and storing it in the function cell of the symbol. This lambda expression thus becomes the function definition of the symbol. (The term “function definition”, meaning the contents of the function cell, is derived from the idea that <code>defun</code> gives the symbol its definition as a function.) <code>defsubst</code> and <code>defalias</code> are two other ways of defining a function. See <a href="functions">Functions</a>. </p> <p><code>defmacro</code> defines a symbol as a macro. It creates a macro object and stores it in the function cell of the symbol. Note that a given symbol can be a macro or a function, but not both at once, because both macro and function definitions are kept in the function cell, and that cell can hold only one Lisp object at any given time. See <a href="macros">Macros</a>. </p> <p>As previously noted, Emacs Lisp allows the same symbol to be defined both as a variable (e.g., with <code>defvar</code>) and as a function or macro (e.g., with <code>defun</code>). Such definitions do not conflict. </p> <p>These definitions also act as guides for programming tools. For example, the <kbd>C-h f</kbd> and <kbd>C-h v</kbd> commands create help buffers containing links to the relevant variable, function, or macro definitions. See <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Name-Help.html#Name-Help">Name Help</a> in <cite>The GNU Emacs Manual</cite>. </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/Definitions.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Definitions.html</a>
+ </p>
+</div>