]> code.delx.au - gnu-emacs/blobdiff - doc/lispref/macros.texi
Merge changes from emacs-24; up to 2012-04-26T02:03:19Z!ueno@unixuser.org
[gnu-emacs] / doc / lispref / macros.texi
index dca88d2b7c7bd465da0ee781199d0f4a70c77032..b9b0e03c65aa4f00a0295d84b975d8c517853c55 100644 (file)
@@ -1,9 +1,8 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990-1995, 1998, 2001-2012  Free Software Foundation, Inc.
+@c Copyright (C) 1990-1995, 1998, 2001-2012 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
-@setfilename ../../info/macros
-@node Macros, Customization, Functions, Top
+@node Macros
 @chapter Macros
 @cindex macros
 
@@ -110,7 +109,7 @@ If @var{environment} is provided, it specifies an alist of macro
 definitions that shadow the currently defined macros.  Byte compilation
 uses this feature.
 
-@smallexample
+@example
 @group
 (defmacro inc (var)
     (list 'setq var (list '1+ var)))
@@ -132,7 +131,7 @@ uses this feature.
 (macroexpand '(inc2 r s))
      @result{} (progn (inc r) (inc s))  ; @r{@code{inc} not expanded here.}
 @end group
-@end smallexample
+@end example
 @end defun
 
 
@@ -146,10 +145,10 @@ Repeating the example used for @code{macroexpand} above with
 @code{macroexpand-all}, we see that @code{macroexpand-all} @emph{does}
 expand the embedded calls to @code{inc}:
 
-@smallexample
+@example
 (macroexpand-all '(inc2 r s))
      @result{} (progn (setq r (1+ r)) (setq s (1+ s)))
-@end smallexample
+@end example
 
 @end defun
 
@@ -258,7 +257,8 @@ Specify how to indent calls to this macro.  @xref{Indenting Macros},
 for more details.
 
 @item (doc-string @var{number})
-Specify which element of the macro is the doc string, if any.
+Specify which element of the macro is the documentation string, if
+any.
 @end table
 
 A @code{declare} form only has its special effect in the body of a
@@ -332,14 +332,15 @@ following macro (used to facilitate iteration) illustrates the
 problem.  This macro allows us to write a ``for'' loop construct.
 
 @findex for
-@smallexample
+@example
 @group
 (defmacro for (var from init to final do &rest body)
   "Execute a simple \"for\" loop.
 For example, (for i from 1 to 10 do (print i))."
   (list 'let (list (list var init))
-        (cons 'while (cons (list '<= var final)
-                           (append body (list (list 'inc var)))))))
+        (cons 'while
+              (cons (list '<= var final)
+                    (append body (list (list 'inc var)))))))
 @end group
 @result{} for
 
@@ -363,7 +364,7 @@ For example, (for i from 1 to 10 do (print i))."
      @print{}3       9
 @result{} nil
 @end group
-@end smallexample
+@end example
 
 @noindent
 The arguments @code{from}, @code{to}, and @code{do} in this macro are
@@ -373,7 +374,7 @@ in those positions in the macro call.
 
 Here's an equivalent definition simplified through use of backquote:
 
-@smallexample
+@example
 @group
 (defmacro for (var from init to final do &rest body)
   "Execute a simple \"for\" loop.
@@ -383,7 +384,7 @@ For example, (for i from 1 to 10 do (print i))."
        ,@@body
        (inc ,var))))
 @end group
-@end smallexample
+@end example
 
 Both forms of this definition (with backquote and without) suffer from
 the defect that @var{final} is evaluated on every iteration.  If
@@ -398,7 +399,7 @@ producing an expansion that evaluates the argument expressions exactly
 once unless repeated evaluation is part of the intended purpose of the
 macro.  Here is a correct expansion for the @code{for} macro:
 
-@smallexample
+@example
 @group
 (let ((i 1)
       (max 3))
@@ -407,11 +408,11 @@ macro.  Here is a correct expansion for the @code{for} macro:
     (princ (format "%d      %d" i square))
     (inc i)))
 @end group
-@end smallexample
+@end example
 
 Here is a macro definition that creates this expansion:
 
-@smallexample
+@example
 @group
 (defmacro for (var from init to final do &rest body)
   "Execute a simple for loop: (for i from 1 to 10 do (print i))."
@@ -421,7 +422,7 @@ Here is a macro definition that creates this expansion:
        ,@@body
        (inc ,var))))
 @end group
-@end smallexample
+@end example
 
   Unfortunately, this fix introduces another problem,
 described in the following section.
@@ -434,7 +435,7 @@ described in the following section.
 follows to make the expansion evaluate the macro arguments the proper
 number of times:
 
-@smallexample
+@example
 @group
 (defmacro for (var from init to final do &rest body)
   "Execute a simple for loop: (for i from 1 to 10 do (print i))."
@@ -446,14 +447,14 @@ number of times:
        ,@@body
        (inc ,var))))
 @end group
-@end smallexample
+@end example
 @end ifnottex
 
   The new definition of @code{for} has a new problem: it introduces a
 local variable named @code{max} which the user does not expect.  This
 causes trouble in examples such as the following:
 
-@smallexample
+@example
 @group
 (let ((max 0))
   (for x from 0 to 10 do
@@ -461,7 +462,7 @@ causes trouble in examples such as the following:
       (if (< max this)
           (setq max this)))))
 @end group
-@end smallexample
+@end example
 
 @noindent
 The references to @code{max} inside the body of the @code{for}, which
@@ -477,7 +478,7 @@ put it into the program later.  It will never appear anywhere except
 where put by @code{for}.  Here is a definition of @code{for} that works
 this way:
 
-@smallexample
+@example
 @group
 (defmacro for (var from init to final do &rest body)
   "Execute a simple for loop: (for i from 1 to 10 do (print i))."
@@ -488,7 +489,7 @@ this way:
          ,@@body
          (inc ,var)))))
 @end group
-@end smallexample
+@end example
 
 @noindent
 This creates an uninterned symbol named @code{max} and puts it in the
@@ -604,8 +605,8 @@ either.
 @section Indenting Macros
 
   Within a macro definition, you can use the @code{declare} form
-(@pxref{Defining Macros}) to specify how to @key{TAB} should indent
-calls to the macro.  An indentation specifiction is written like this:
+(@pxref{Defining Macros}) to specify how @key{TAB} should indent
+calls to the macro.  An indentation specification is written like this:
 
 @example
 (declare (indent @var{indent-spec}))