diff options
Diffstat (limited to 'doc/lispintro')
| -rw-r--r-- | doc/lispintro/ChangeLog | 12 | ||||
| -rw-r--r-- | doc/lispintro/emacs-lisp-intro.texi | 62 |
2 files changed, 44 insertions, 30 deletions
diff --git a/doc/lispintro/ChangeLog b/doc/lispintro/ChangeLog index 93084e76203..be9f9f963c0 100644 --- a/doc/lispintro/ChangeLog +++ b/doc/lispintro/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2013-04-23 Xue Fuqiao <xfq.free@gmail.com> | ||
| 2 | |||
| 3 | * emacs-lisp-intro.texi (Complications, defvar): Refine the doc | ||
| 4 | about Lisp macros. (http://lists.gnu.org/archive/html/emacs-devel/2013-04/msg00618.html) | ||
| 5 | |||
| 6 | 2013-04-21 Xue Fuqiao <xfq.free@gmail.com> | ||
| 7 | |||
| 8 | * emacs-lisp-intro.texi (defcustom, defun) | ||
| 9 | (simplified-beginning-of-buffer, defvar, Building Robots, Review) | ||
| 10 | (save-excursion): `defun' and `defcustom' are now macros rather | ||
| 11 | than special forms. (Bug#13853) | ||
| 12 | |||
| 1 | 2013-03-16 Glenn Morris <rgm@gnu.org> | 13 | 2013-03-16 Glenn Morris <rgm@gnu.org> |
| 2 | 14 | ||
| 3 | * emacs-lisp-intro.texi: Add some stuff specific to www.gnu.org. | 15 | * emacs-lisp-intro.texi: Add some stuff specific to www.gnu.org. |
diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index c42ed210cbc..7831603124e 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | 37 | ||
| 38 | @set edition-number 3.10 | 38 | @set edition-number 3.10 |
| 39 | @set update-date 28 October 2009 | 39 | @set update-date 28 October 2009 |
| 40 | @c FIXME can this be updated? -- xfq | ||
| 40 | 41 | ||
| 41 | @ignore | 42 | @ignore |
| 42 | ## Summary of shell commands to create various output formats: | 43 | ## Summary of shell commands to create various output formats: |
| @@ -456,7 +457,7 @@ Practicing Evaluation | |||
| 456 | How To Write Function Definitions | 457 | How To Write Function Definitions |
| 457 | 458 | ||
| 458 | * Primitive Functions:: | 459 | * Primitive Functions:: |
| 459 | * defun:: The @code{defun} special form. | 460 | * defun:: The @code{defun} macro. |
| 460 | * Install:: Install a function definition. | 461 | * Install:: Install a function definition. |
| 461 | * Interactive:: Making a function interactive. | 462 | * Interactive:: Making a function interactive. |
| 462 | * Interactive Options:: Different options for @code{interactive}. | 463 | * Interactive Options:: Different options for @code{interactive}. |
| @@ -1617,11 +1618,16 @@ the symbol's value as a @dfn{variable}. This situation is described | |||
| 1617 | in the section on variables. (@xref{Variables}.) | 1618 | in the section on variables. (@xref{Variables}.) |
| 1618 | 1619 | ||
| 1619 | @cindex Special form | 1620 | @cindex Special form |
| 1620 | The second complication occurs because some functions are unusual and do | 1621 | The second complication occurs because some functions are unusual and |
| 1621 | not work in the usual manner. Those that don't are called @dfn{special | 1622 | do not work in the usual manner. Those that don't are called |
| 1622 | forms}. They are used for special jobs, like defining a function, and | 1623 | @dfn{special forms}. They are used for special jobs, like defining a |
| 1623 | there are not many of them. In the next few chapters, you will be | 1624 | function, and there are not many of them. In the next few chapters, |
| 1624 | introduced to several of the more important special forms. | 1625 | you will be introduced to several of the more important special forms. |
| 1626 | And there are also @dfn{macros}. Macro is a construct defined in | ||
| 1627 | Lisp, which differs from a function in that it translates a Lisp | ||
| 1628 | expression into another expression which is to be evaluated instead of | ||
| 1629 | the original expression. (@xref{Lisp macro}.) | ||
| 1630 | |||
| 1625 | 1631 | ||
| 1626 | The third and final complication is this: if the function that the | 1632 | The third and final complication is this: if the function that the |
| 1627 | Lisp interpreter is looking at is not a special form, and if it is part | 1633 | Lisp interpreter is looking at is not a special form, and if it is part |
| @@ -3094,18 +3100,15 @@ unless you investigate, you won't know whether an already-written | |||
| 3094 | function is written in Emacs Lisp or C. | 3100 | function is written in Emacs Lisp or C. |
| 3095 | 3101 | ||
| 3096 | @node defun | 3102 | @node defun |
| 3097 | @section The @code{defun} Special Form | 3103 | @section The @code{defun} Macro |
| 3098 | @findex defun | 3104 | @findex defun |
| 3099 | @cindex Special form of @code{defun} | ||
| 3100 | 3105 | ||
| 3101 | @cindex @samp{function definition} defined | 3106 | @cindex @samp{function definition} defined |
| 3102 | In Lisp, a symbol such as @code{mark-whole-buffer} has code attached to | 3107 | In Lisp, a symbol such as @code{mark-whole-buffer} has code attached to |
| 3103 | it that tells the computer what to do when the function is called. | 3108 | it that tells the computer what to do when the function is called. |
| 3104 | This code is called the @dfn{function definition} and is created by | 3109 | This code is called the @dfn{function definition} and is created by |
| 3105 | evaluating a Lisp expression that starts with the symbol @code{defun} | 3110 | evaluating a Lisp expression that starts with the symbol @code{defun} |
| 3106 | (which is an abbreviation for @emph{define function}). Because | 3111 | (which is an abbreviation for @emph{define function}). |
| 3107 | @code{defun} does not evaluate its arguments in the usual way, it is | ||
| 3108 | called a @dfn{special form}. | ||
| 3109 | 3112 | ||
| 3110 | In subsequent sections, we will look at function definitions from the | 3113 | In subsequent sections, we will look at function definitions from the |
| 3111 | Emacs source code, such as @code{mark-whole-buffer}. In this section, | 3114 | Emacs source code, such as @code{mark-whole-buffer}. In this section, |
| @@ -4254,7 +4257,7 @@ On the other hand, this function returns @code{nil} if the test is false. | |||
| 4254 | @findex point | 4257 | @findex point |
| 4255 | @findex mark | 4258 | @findex mark |
| 4256 | 4259 | ||
| 4257 | The @code{save-excursion} function is the fourth and final special form | 4260 | The @code{save-excursion} function is the third and final special form |
| 4258 | that we will discuss in this chapter. | 4261 | that we will discuss in this chapter. |
| 4259 | 4262 | ||
| 4260 | In Emacs Lisp programs used for editing, the @code{save-excursion} | 4263 | In Emacs Lisp programs used for editing, the @code{save-excursion} |
| @@ -4381,9 +4384,9 @@ within the body of a @code{let} expression. It looks like this: | |||
| 4381 | @node Review | 4384 | @node Review |
| 4382 | @section Review | 4385 | @section Review |
| 4383 | 4386 | ||
| 4384 | In the last few chapters we have introduced a fair number of functions | 4387 | In the last few chapters we have introduced a macro and a fair number |
| 4385 | and special forms. Here they are described in brief, along with a few | 4388 | of functions and special forms. Here they are described in brief, |
| 4386 | similar functions that have not been mentioned yet. | 4389 | along with a few similar functions that have not been mentioned yet. |
| 4387 | 4390 | ||
| 4388 | @table @code | 4391 | @table @code |
| 4389 | @item eval-last-sexp | 4392 | @item eval-last-sexp |
| @@ -4393,10 +4396,10 @@ invoked with an argument; in that case, the output is printed in the | |||
| 4393 | current buffer. This command is normally bound to @kbd{C-x C-e}. | 4396 | current buffer. This command is normally bound to @kbd{C-x C-e}. |
| 4394 | 4397 | ||
| 4395 | @item defun | 4398 | @item defun |
| 4396 | Define function. This special form has up to five parts: the name, | 4399 | Define function. This macro has up to five parts: the name, a |
| 4397 | a template for the arguments that will be passed to the function, | 4400 | template for the arguments that will be passed to the function, |
| 4398 | documentation, an optional interactive declaration, and the body of the | 4401 | documentation, an optional interactive declaration, and the body of |
| 4399 | definition. | 4402 | the definition. |
| 4400 | 4403 | ||
| 4401 | @need 1250 | 4404 | @need 1250 |
| 4402 | For example, in an early version of Emacs, the function definition was | 4405 | For example, in an early version of Emacs, the function definition was |
| @@ -4803,7 +4806,7 @@ leave mark at previous position." | |||
| 4803 | @end smallexample | 4806 | @end smallexample |
| 4804 | 4807 | ||
| 4805 | Like all function definitions, this definition has five parts following | 4808 | Like all function definitions, this definition has five parts following |
| 4806 | the special form @code{defun}: | 4809 | the macro @code{defun}: |
| 4807 | 4810 | ||
| 4808 | @enumerate | 4811 | @enumerate |
| 4809 | @item | 4812 | @item |
| @@ -9293,7 +9296,7 @@ have a value. If the variable already has a value, @code{defvar} does | |||
| 9293 | not override the existing value. Second, @code{defvar} has a | 9296 | not override the existing value. Second, @code{defvar} has a |
| 9294 | documentation string. | 9297 | documentation string. |
| 9295 | 9298 | ||
| 9296 | (Another special form, @code{defcustom}, is designed for variables | 9299 | (There is a related macro, @code{defcustom}, designed for variables |
| 9297 | that people customize. It has more features than @code{defvar}. | 9300 | that people customize. It has more features than @code{defvar}. |
| 9298 | (@xref{defcustom, , Setting Variables with @code{defcustom}}.) | 9301 | (@xref{defcustom, , Setting Variables with @code{defcustom}}.) |
| 9299 | 9302 | ||
| @@ -11300,11 +11303,11 @@ Let's expand on the metaphor in which a computer program is a robot. | |||
| 11300 | 11303 | ||
| 11301 | A function definition provides the blueprints for a robot. When you | 11304 | A function definition provides the blueprints for a robot. When you |
| 11302 | install a function definition, that is, when you evaluate a | 11305 | install a function definition, that is, when you evaluate a |
| 11303 | @code{defun} special form, you install the necessary equipment to | 11306 | @code{defun} macro, you install the necessary equipment to build |
| 11304 | build robots. It is as if you were in a factory, setting up an | 11307 | robots. It is as if you were in a factory, setting up an assembly |
| 11305 | assembly line. Robots with the same name are built according to the | 11308 | line. Robots with the same name are built according to the same |
| 11306 | same blueprints. So they have, as it were, the same `model number', | 11309 | blueprints. So they have, as it were, the same `model number', but a |
| 11307 | but a different `serial number'. | 11310 | different `serial number'. |
| 11308 | 11311 | ||
| 11309 | We often say that a recursive function `calls itself'. What we mean | 11312 | We often say that a recursive function `calls itself'. What we mean |
| 11310 | is that the instructions in a recursive function cause the Lisp | 11313 | is that the instructions in a recursive function cause the Lisp |
| @@ -16971,10 +16974,9 @@ definitions; but you can write @code{defuns} in your @file{.emacs} | |||
| 16971 | file. Indeed, you can write any Lisp expression in your @file{.emacs} | 16974 | file. Indeed, you can write any Lisp expression in your @file{.emacs} |
| 16972 | file.) | 16975 | file.) |
| 16973 | 16976 | ||
| 16974 | The @code{customize} feature depends on the @code{defcustom} special | 16977 | The @code{customize} feature depends on the @code{defcustom} macro. |
| 16975 | form. Although you can use @code{defvar} or @code{setq} for variables | 16978 | Although you can use @code{defvar} or @code{setq} for variables that |
| 16976 | that users set, the @code{defcustom} special form is designed for the | 16979 | users set, the @code{defcustom} macro is designed for the job. |
| 16977 | job. | ||
| 16978 | 16980 | ||
| 16979 | You can use your knowledge of @code{defvar} for writing the | 16981 | You can use your knowledge of @code{defvar} for writing the |
| 16980 | first three arguments for @code{defcustom}. The first argument to | 16982 | first three arguments for @code{defcustom}. The first argument to |