/[emacs]/emacs/lispref/macros.texi
ViewVC logotype

Diff of /emacs/lispref/macros.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10.8.1 by miles, Fri Apr 4 06:20:42 2003 UTC revision 1.10.8.2 by miles, Tue Oct 14 23:10:12 2003 UTC
# Line 30  instead.  @xref{Inline Functions}. Line 30  instead.  @xref{Inline Functions}.
30  * Backquote::               Easier construction of list structure.  * Backquote::               Easier construction of list structure.
31  * Problems with Macros::    Don't evaluate the macro arguments too many times.  * Problems with Macros::    Don't evaluate the macro arguments too many times.
32                                Don't hide the user's variables.                                Don't hide the user's variables.
33    * Indenting Macros::        Specifying how to indent macro calls.
34  @end menu  @end menu
35    
36  @node Simple Macro  @node Simple Macro
# Line 205  any @code{interactive} declaration is ig Line 206  any @code{interactive} declaration is ig
206  called interactively.  called interactively.
207  @end defspec  @end defspec
208    
209      The body of the macro definition can include a @code{declare} form,
210    which can specify how @key{TAB} should indent macro calls, and how to
211    step through them for Edebug.
212    
213    @defspec declare @var{specs}...
214    This special form is used at top level in a macro definition to
215    specify various additional information about it.  Two kinds of
216    specification are currently supported:
217    
218    @table @code
219    @item (edebug @var{edebug-form-spec})
220    Specify how to step through macro calls for Edebug.
221    @xref{Instrumenting Macro Calls}, for more details.
222    
223    @item (indent @var{indent-spec})
224    Specify how to indent calls to this macro.  @xref{Indenting Macros},
225    for more details.
226    @end table
227    @end defspec
228    
229      No macro absolutely needs a @code{declare} form, because that form
230    has no effect on how the macro expands, on what the macro means in the
231    program.  It only affects secondary features: indentation and Edebug.
232    
233  @node Backquote  @node Backquote
234  @section Backquote  @section Backquote
235  @cindex backquote (list substitution)  @cindex backquote (list substitution)
# Line 636  One way to avoid pathological cases like Line 661  One way to avoid pathological cases like
661  allocation construct.  You wouldn't use @code{setcar} on a constant such  allocation construct.  You wouldn't use @code{setcar} on a constant such
662  as @code{'(nil)}, so naturally you won't use it on @code{(empty-object)}  as @code{'(nil)}, so naturally you won't use it on @code{(empty-object)}
663  either.  either.
664    
665    @node Indenting Macros
666    @section Indenting Macros
667    
668      You can use the @code{declare} form in the macro definition to
669    specify how to @key{TAB} should indent indent calls to the macro.  You
670    write it like this:
671    
672    @example
673    (declare (indent @var{indent-spec}))
674    @end example
675    
676    @noindent
677    Here are the possibilities for @var{indent-spec}:
678    
679    @table @asis
680    @item @code{nil}
681    This is the same as no property---use the standard indentation pattern.
682    @item @code{defun}
683    Handle this function like a @samp{def} construct: treat the second
684    line as the start of a @dfn{body}.
685    @item a number, @var{number}
686    The first @var{number} arguments of the function are
687    @dfn{distinguished} arguments; the rest are considered the body
688    of the expression.  A line in the expression is indented according to
689    whether the first argument on it is distinguished or not.  If the
690    argument is part of the body, the line is indented @code{lisp-body-indent}
691    more columns than the open-parenthesis starting the containing
692    expression.  If the argument is distinguished and is either the first
693    or second argument, it is indented @emph{twice} that many extra columns.
694    If the argument is distinguished and not the first or second argument,
695    the line uses the standard pattern.
696    @item a symbol, @var{symbol}
697    @var{symbol} should be a function name; that function is called to
698    calculate the indentation of a line within this expression.  The
699    function receives two arguments:
700    @table @asis
701    @item @var{state}
702    The value returned by @code{parse-partial-sexp} (a Lisp primitive for
703    indentation and nesting computation) when it parses up to the
704    beginning of this line.
705    @item @var{pos}
706    The position at which the line being indented begins.
707    @end table
708    @noindent
709    It should return either a number, which is the number of columns of
710    indentation for that line, or a list whose car is such a number.  The
711    difference between returning a number and returning a list is that a
712    number says that all following lines at the same nesting level should
713    be indented just like this one; a list says that following lines might
714    call for different indentations.  This makes a difference when the
715    indentation is being computed by @kbd{C-M-q}; if the value is a
716    number, @kbd{C-M-q} need not recalculate indentation for the following
717    lines until the end of the list.
718    @end table
719    
720    @ignore
721       arch-tag: d4cce66d-1047-45c3-bfde-db6719d6e82b
722    @end ignore

Legend:
Removed from v.1.10.8.1  
changed lines
  Added in v.1.10.8.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26