1370 lines
47 KiB
Plaintext
1370 lines
47 KiB
Plaintext
# SOME DESCRIPTIVE TITLE
|
|
# Copyright (C) YEAR Free Software Foundation, Inc.
|
|
# This file is distributed under the same license as the PACKAGE package.
|
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
#
|
|
#, fuzzy
|
|
msgid ""
|
|
msgstr ""
|
|
"Project-Id-Version: PACKAGE VERSION\n"
|
|
"POT-Creation-Date: 2021-11-07 12:11+0900\n"
|
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
"Language: \n"
|
|
"MIME-Version: 1.0\n"
|
|
"Content-Type: text/plain; charset=UTF-8\n"
|
|
"Content-Transfer-Encoding: 8bit\n"
|
|
|
|
#. type: chapter
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:6
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:7
|
|
#, no-wrap
|
|
msgid "Macros"
|
|
msgstr ""
|
|
|
|
#. type: cindex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:8
|
|
#, no-wrap
|
|
msgid "macros"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:15
|
|
msgid ""
|
|
"@dfn{Macros} enable you to define new control constructs and other language "
|
|
"features. A macro is defined much like a function, but instead of telling "
|
|
"how to compute a value, it tells how to compute another Lisp expression "
|
|
"which will in turn compute the value. We call this expression the "
|
|
"@dfn{expansion} of the macro."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:20
|
|
msgid ""
|
|
"Macros can do this because they operate on the unevaluated expressions for "
|
|
"the arguments, not on the argument values as functions do. They can "
|
|
"therefore construct an expansion containing these argument expressions or "
|
|
"parts of them."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:24
|
|
msgid ""
|
|
"If you are using a macro to do something an ordinary function could do, just "
|
|
"for the sake of speed, consider using an inline function instead. "
|
|
"@xref{Inline Functions}."
|
|
msgstr ""
|
|
|
|
#. type: node
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:35
|
|
#, no-wrap
|
|
msgid "Simple Macro"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
msgid "A basic example."
|
|
msgstr ""
|
|
|
|
#. type: node
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:63
|
|
#, no-wrap
|
|
msgid "Expansion"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
msgid "How, when and why macros are expanded."
|
|
msgstr ""
|
|
|
|
#. type: node
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:169
|
|
#, no-wrap
|
|
msgid "Compiling Macros"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
msgid "How macros are expanded by the compiler."
|
|
msgstr ""
|
|
|
|
#. type: section
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:201
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:202
|
|
#, no-wrap
|
|
msgid "Defining Macros"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
msgid "How to write a macro definition."
|
|
msgstr ""
|
|
|
|
#. type: node
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:256
|
|
#, no-wrap
|
|
msgid "Problems with Macros"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
msgid ""
|
|
"Don't evaluate the macro arguments too many times. Don't hide the user's "
|
|
"variables."
|
|
msgstr ""
|
|
|
|
#. type: section
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:582
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:583
|
|
#, no-wrap
|
|
msgid "Indenting Macros"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:33
|
|
msgid "Specifying how to indent macro calls."
|
|
msgstr ""
|
|
|
|
#. type: section
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:36
|
|
#, no-wrap
|
|
msgid "A Simple Example of a Macro"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:42
|
|
msgid ""
|
|
"Suppose we would like to define a Lisp construct to increment a variable "
|
|
"value, much like the @code{++} operator in C@. We would like to write "
|
|
"@code{(inc x)} and have the effect of @code{(setq x (1+ x))}. Here's a "
|
|
"macro definition that does the job:"
|
|
msgstr ""
|
|
|
|
#. type: findex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:43
|
|
#, no-wrap
|
|
msgid "inc"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:48
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro inc (var)\n"
|
|
" (list 'setq var (list '1+ var)))\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:57
|
|
msgid ""
|
|
"When this is called with @code{(inc x)}, the argument @var{var} is the "
|
|
"symbol @code{x}---@emph{not} the @emph{value} of @code{x}, as it would be in "
|
|
"a function. The body of the macro uses this to construct the expansion, "
|
|
"which is @code{(setq x (1+ x))}. Once the macro definition returns this "
|
|
"expansion, Lisp proceeds to evaluate it, thus incrementing @code{x}."
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:58
|
|
#, no-wrap
|
|
msgid "macrop object"
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:61
|
|
msgid ""
|
|
"This predicate tests whether its argument is a macro, and returns @code{t} "
|
|
"if so, @code{nil} otherwise."
|
|
msgstr ""
|
|
|
|
#. type: section
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:64
|
|
#, no-wrap
|
|
msgid "Expansion of a Macro Call"
|
|
msgstr ""
|
|
|
|
#. type: cindex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:65
|
|
#, no-wrap
|
|
msgid "expansion of macros"
|
|
msgstr ""
|
|
|
|
#. type: cindex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:66
|
|
#, no-wrap
|
|
msgid "macro call"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:71
|
|
msgid ""
|
|
"A macro call looks just like a function call in that it is a list which "
|
|
"starts with the name of the macro. The rest of the elements of the list are "
|
|
"the arguments of the macro."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:78
|
|
msgid ""
|
|
"Evaluation of the macro call begins like evaluation of a function call "
|
|
"except for one crucial difference: the macro arguments are the actual "
|
|
"expressions appearing in the macro call. They are not evaluated before they "
|
|
"are given to the macro definition. By contrast, the arguments of a function "
|
|
"are results of evaluating the elements of the function call list."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:84
|
|
msgid ""
|
|
"Having obtained the arguments, Lisp invokes the macro definition just as a "
|
|
"function is invoked. The argument variables of the macro are bound to the "
|
|
"argument values from the macro call, or to a list of them in the case of a "
|
|
"@code{&rest} argument. And the macro body executes and returns its value "
|
|
"just as a function body does."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:90
|
|
msgid ""
|
|
"The second crucial difference between macros and functions is that the value "
|
|
"returned by the macro body is an alternate Lisp expression, also known as "
|
|
"the @dfn{expansion} of the macro. The Lisp interpreter proceeds to evaluate "
|
|
"the expansion as soon as it comes back from the macro."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:94
|
|
msgid ""
|
|
"Since the expansion is evaluated in the normal manner, it may contain calls "
|
|
"to other macros. It may even be a call to the same macro, though this is "
|
|
"unusual."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:98
|
|
msgid ""
|
|
"Note that Emacs tries to expand macros when loading an uncompiled Lisp "
|
|
"file. This is not always possible, but if it is, it speeds up subsequent "
|
|
"execution. @xref{How Programs Do Loading}."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:101
|
|
msgid ""
|
|
"You can see the expansion of a given macro call by calling "
|
|
"@code{macroexpand}."
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:102
|
|
#, no-wrap
|
|
msgid "macroexpand form &optional environment"
|
|
msgstr ""
|
|
|
|
#. type: cindex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:103
|
|
#, no-wrap
|
|
msgid "macro expansion"
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:109
|
|
msgid ""
|
|
"This function expands @var{form}, if it is a macro call. If the result is "
|
|
"another macro call, it is expanded in turn, until something which is not a "
|
|
"macro call results. That is the value returned by @code{macroexpand}. If "
|
|
"@var{form} is not a macro call to begin with, it is returned as given."
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:113
|
|
msgid ""
|
|
"Note that @code{macroexpand} does not look at the subexpressions of "
|
|
"@var{form} (although some macro definitions may do so). Even if they are "
|
|
"macro calls themselves, @code{macroexpand} does not expand them."
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:117
|
|
msgid ""
|
|
"The function @code{macroexpand} does not expand calls to inline functions. "
|
|
"Normally there is no need for that, since a call to an inline function is no "
|
|
"harder to understand than a call to an ordinary function."
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:121
|
|
msgid ""
|
|
"If @var{environment} is provided, it specifies an alist of macro definitions "
|
|
"that shadow the currently defined macros. Byte compilation uses this "
|
|
"feature."
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:126
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro inc (var)\n"
|
|
" (list 'setq var (list '1+ var)))\n"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:131
|
|
#, no-wrap
|
|
msgid ""
|
|
"(macroexpand '(inc r))\n"
|
|
" @result{} (setq r (1+ r))\n"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:136
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro inc2 (var1 var2)\n"
|
|
" (list 'progn (list 'inc var1) (list 'inc var2)))\n"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:141
|
|
#, no-wrap
|
|
msgid ""
|
|
"(macroexpand '(inc2 r s))\n"
|
|
" @result{} (progn (inc r) (inc s)) ; @r{@code{inc} not expanded "
|
|
"here.}\n"
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:146
|
|
#, no-wrap
|
|
msgid "macroexpand-all form &optional environment"
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:151
|
|
msgid ""
|
|
"@code{macroexpand-all} expands macros like @code{macroexpand}, but will look "
|
|
"for and expand all macros in @var{form}, not just at the top-level. If no "
|
|
"macros are expanded, the return value is @code{eq} to @var{form}."
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:155
|
|
msgid ""
|
|
"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}:"
|
|
msgstr ""
|
|
|
|
#. type: example
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:159
|
|
#, no-wrap
|
|
msgid ""
|
|
"(macroexpand-all '(inc2 r s))\n"
|
|
" @result{} (progn (setq r (1+ r)) (setq s (1+ s)))\n"
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:163
|
|
#, no-wrap
|
|
msgid "macroexpand-1 form &optional environment"
|
|
msgstr ""
|
|
|
|
#. type: defun
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:167
|
|
msgid ""
|
|
"This function expands macros like @code{macroexpand}, but it only performs "
|
|
"one step of the expansion: if the result is another macro call, "
|
|
"@code{macroexpand-1} will not expand it."
|
|
msgstr ""
|
|
|
|
#. type: section
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:170
|
|
#, no-wrap
|
|
msgid "Macros and Byte Compilation"
|
|
msgstr ""
|
|
|
|
#. type: cindex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:171
|
|
#, no-wrap
|
|
msgid "byte-compiling macros"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:177
|
|
msgid ""
|
|
"You might ask why we take the trouble to compute an expansion for a macro "
|
|
"and then evaluate the expansion. Why not have the macro body produce the "
|
|
"desired results directly? The reason has to do with compilation."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:186
|
|
msgid ""
|
|
"When a macro call appears in a Lisp program being compiled, the Lisp "
|
|
"compiler calls the macro definition just as the interpreter would, and "
|
|
"receives an expansion. But instead of evaluating this expansion, it "
|
|
"compiles the expansion as if it had appeared directly in the program. As a "
|
|
"result, the compiled code produces the value and side effects intended for "
|
|
"the macro, but executes at full compiled speed. This would not work if the "
|
|
"macro body computed the value and side effects itself---they would be "
|
|
"computed at compile time, which is not useful."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:192
|
|
msgid ""
|
|
"In order for compilation of macro calls to work, the macros must already be "
|
|
"defined in Lisp when the calls to them are compiled. The compiler has a "
|
|
"special feature to help you do this: if a file being compiled contains a "
|
|
"@code{defmacro} form, the macro is defined temporarily for the rest of the "
|
|
"compilation of that file."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:200
|
|
msgid ""
|
|
"Byte-compiling a file also executes any @code{require} calls at top-level in "
|
|
"the file, so you can ensure that necessary macro definitions are available "
|
|
"during compilation by requiring the files that define them (@pxref{Named "
|
|
"Features}). To avoid loading the macro definition files when someone "
|
|
"@emph{runs} the compiled program, write @code{eval-when-compile} around the "
|
|
"@code{require} calls (@pxref{Eval During Compile})."
|
|
msgstr ""
|
|
|
|
#. type: cindex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:203
|
|
#, no-wrap
|
|
msgid "defining macros"
|
|
msgstr ""
|
|
|
|
#. type: cindex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:204
|
|
#, no-wrap
|
|
msgid "macro, how to define"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:210
|
|
msgid ""
|
|
"A Lisp macro object is a list whose @sc{car} is @code{macro}, and whose "
|
|
"@sc{cdr} is a function. Expansion of the macro works by applying the "
|
|
"function (with @code{apply}) to the list of @emph{unevaluated} arguments "
|
|
"from the macro call."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:216
|
|
msgid ""
|
|
"It is possible to use an anonymous Lisp macro just like an anonymous "
|
|
"function, but this is never done, because it does not make sense to pass an "
|
|
"anonymous macro to functionals such as @code{mapcar}. In practice, all Lisp "
|
|
"macros have names, and they are almost always defined with the "
|
|
"@code{defmacro} macro."
|
|
msgstr ""
|
|
|
|
#. type: defmac
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:217
|
|
#, no-wrap
|
|
msgid "defmacro name args [doc] [declare] body@dots{}"
|
|
msgstr ""
|
|
|
|
#. type: defmac
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:220
|
|
msgid ""
|
|
"@code{defmacro} defines the symbol @var{name} (which should not be quoted) "
|
|
"as a macro that looks like this:"
|
|
msgstr ""
|
|
|
|
#. type: example
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:223
|
|
#, no-wrap
|
|
msgid "(macro lambda @var{args} . @var{body})\n"
|
|
msgstr ""
|
|
|
|
#. type: defmac
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:231
|
|
msgid ""
|
|
"(Note that the @sc{cdr} of this list is a lambda expression.) This macro "
|
|
"object is stored in the function cell of @var{name}. The meaning of "
|
|
"@var{args} is the same as in a function, and the keywords @code{&rest} and "
|
|
"@code{&optional} may be used (@pxref{Argument List}). Neither @var{name} "
|
|
"nor @var{args} should be quoted. The return value of @code{defmacro} is "
|
|
"undefined."
|
|
msgstr ""
|
|
|
|
#. type: defmac
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:237
|
|
msgid ""
|
|
"@var{doc}, if present, should be a string specifying the macro's "
|
|
"documentation string. @var{declare}, if present, should be a @code{declare} "
|
|
"form specifying metadata for the macro (@pxref{Declare Form}). Note that "
|
|
"macros cannot have interactive declarations, since they cannot be called "
|
|
"interactively."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:242
|
|
msgid ""
|
|
"Macros often need to construct large list structures from a mixture of "
|
|
"constants and nonconstant parts. To make this easier, use the @samp{`} "
|
|
"syntax (@pxref{Backquote}). For example:"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:248
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro t-becomes-nil (variable)\n"
|
|
" `(if (eq ,variable t)\n"
|
|
" (setq ,variable nil)))\n"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:253
|
|
#, no-wrap
|
|
msgid ""
|
|
"(t-becomes-nil foo)\n"
|
|
" @equiv{} (if (eq foo t) (setq foo nil))\n"
|
|
msgstr ""
|
|
|
|
#. type: section
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:257
|
|
#, no-wrap
|
|
msgid "Common Problems Using Macros"
|
|
msgstr ""
|
|
|
|
#. type: cindex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:258
|
|
#, no-wrap
|
|
msgid "macro caveats"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:263
|
|
msgid ""
|
|
"Macro expansion can have counterintuitive consequences. This section "
|
|
"describes some important consequences that can lead to trouble, and rules to "
|
|
"follow to avoid trouble."
|
|
msgstr ""
|
|
|
|
#. type: subsection
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:271
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:273
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:274
|
|
#, no-wrap
|
|
msgid "Wrong Time"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:271
|
|
msgid "Do the work in the expansion, not in the macro."
|
|
msgstr ""
|
|
|
|
#. type: node
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:271
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:304
|
|
#, no-wrap
|
|
msgid "Argument Evaluation"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:271
|
|
msgid "The expansion should evaluate each macro arg once."
|
|
msgstr ""
|
|
|
|
#. type: node
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:271
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:407
|
|
#, no-wrap
|
|
msgid "Surprising Local Vars"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:271
|
|
msgid "Local variable bindings in the expansion require special care."
|
|
msgstr ""
|
|
|
|
#. type: node
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:271
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:476
|
|
#, no-wrap
|
|
msgid "Eval During Expansion"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:271
|
|
msgid "Don't evaluate them; put them in the expansion."
|
|
msgstr ""
|
|
|
|
#. type: node
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:271
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:524
|
|
#, no-wrap
|
|
msgid "Repeated Expansion"
|
|
msgstr ""
|
|
|
|
#. type: menuentry
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:271
|
|
msgid "Avoid depending on how many times expansion is done."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:280
|
|
msgid ""
|
|
"The most common problem in writing macros is doing some of the real work "
|
|
"prematurely---while expanding the macro, rather than in the expansion "
|
|
"itself. For instance, one real package had this macro definition:"
|
|
msgstr ""
|
|
|
|
#. type: example
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:285
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro my-set-buffer-multibyte (arg)\n"
|
|
" (if (fboundp 'set-buffer-multibyte)\n"
|
|
" (set-buffer-multibyte arg)))\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:292
|
|
msgid ""
|
|
"With this erroneous macro definition, the program worked fine when "
|
|
"interpreted but failed when compiled. This macro definition called "
|
|
"@code{set-buffer-multibyte} during compilation, which was wrong, and then "
|
|
"did nothing when the compiled package was run. The definition that the "
|
|
"programmer really wanted was this:"
|
|
msgstr ""
|
|
|
|
#. type: example
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:297
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro my-set-buffer-multibyte (arg)\n"
|
|
" (if (fboundp 'set-buffer-multibyte)\n"
|
|
" `(set-buffer-multibyte ,arg)))\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:303
|
|
msgid ""
|
|
"This macro expands, if appropriate, into a call to "
|
|
"@code{set-buffer-multibyte} that will be executed when the compiled program "
|
|
"is actually run."
|
|
msgstr ""
|
|
|
|
#. type: subsection
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:305
|
|
#, no-wrap
|
|
msgid "Evaluating Macro Arguments Repeatedly"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:311
|
|
msgid ""
|
|
"When defining a macro you must pay attention to the number of times the "
|
|
"arguments will be evaluated when the expansion is executed. The following "
|
|
"macro (used to facilitate iteration) illustrates the problem. This macro "
|
|
"allows us to write a for-loop construct."
|
|
msgstr ""
|
|
|
|
#. type: findex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:312
|
|
#, no-wrap
|
|
msgid "for"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:322
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro for (var from init to final do &rest body)\n"
|
|
" \"Execute a simple \\\"for\\\" loop.\n"
|
|
"For example, (for i from 1 to 10 do (print i)).\"\n"
|
|
" (list 'let (list (list var init))\n"
|
|
" (cons 'while\n"
|
|
" (cons (list '<= var final)\n"
|
|
" (append body (list (list 'inc var)))))))\n"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:329
|
|
#, no-wrap
|
|
msgid ""
|
|
"(for i from 1 to 3 do\n"
|
|
" (setq square (* i i))\n"
|
|
" (princ (format \"\\n%d %d\" i square)))\n"
|
|
"@expansion{}\n"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:336
|
|
#, no-wrap
|
|
msgid ""
|
|
"(let ((i 1))\n"
|
|
" (while (<= i 3)\n"
|
|
" (setq square (* i i))\n"
|
|
" (princ (format \"\\n%d %d\" i square))\n"
|
|
" (inc i)))\n"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:343
|
|
#, no-wrap
|
|
msgid ""
|
|
" @print{}1 1\n"
|
|
" @print{}2 4\n"
|
|
" @print{}3 9\n"
|
|
"@result{} nil\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:351
|
|
msgid ""
|
|
"The arguments @code{from}, @code{to}, and @code{do} in this macro are "
|
|
"syntactic sugar; they are entirely ignored. The idea is that you will write "
|
|
"noise words (such as @code{from}, @code{to}, and @code{do}) in those "
|
|
"positions in the macro call."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:353
|
|
msgid "Here's an equivalent definition simplified through use of backquote:"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:363
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro for (var from init to final do &rest body)\n"
|
|
" \"Execute a simple \\\"for\\\" loop.\n"
|
|
"For example, (for i from 1 to 10 do (print i)).\"\n"
|
|
" `(let ((,var ,init))\n"
|
|
" (while (<= ,var ,final)\n"
|
|
" ,@@body\n"
|
|
" (inc ,var))))\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:372
|
|
msgid ""
|
|
"Both forms of this definition (with backquote and without) suffer from the "
|
|
"defect that @var{final} is evaluated on every iteration. If @var{final} is "
|
|
"a constant, this is not a problem. If it is a more complex form, say "
|
|
"@code{(long-complex-calculation x)}, this can slow down the execution "
|
|
"significantly. If @var{final} has side effects, executing it more than once "
|
|
"is probably incorrect."
|
|
msgstr ""
|
|
|
|
#. type: cindex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:373
|
|
#, no-wrap
|
|
msgid "macro argument evaluation"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:378
|
|
msgid ""
|
|
"A well-designed macro definition takes steps to avoid this problem by "
|
|
"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:"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:387
|
|
#, no-wrap
|
|
msgid ""
|
|
"(let ((i 1)\n"
|
|
" (max 3))\n"
|
|
" (while (<= i max)\n"
|
|
" (setq square (* i i))\n"
|
|
" (princ (format \"%d %d\" i square))\n"
|
|
" (inc i)))\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:391
|
|
msgid "Here is a macro definition that creates this expansion:"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:401
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro for (var from init to final do &rest body)\n"
|
|
" \"Execute a simple for loop: (for i from 1 to 10 do (print i)).\"\n"
|
|
" `(let ((,var ,init)\n"
|
|
" (max ,final))\n"
|
|
" (while (<= ,var max)\n"
|
|
" ,@@body\n"
|
|
" (inc ,var))))\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:406
|
|
msgid ""
|
|
"Unfortunately, this fix introduces another problem, described in the "
|
|
"following section."
|
|
msgstr ""
|
|
|
|
#. type: subsection
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:408
|
|
#, no-wrap
|
|
msgid "Local Variables in Macro Expansions"
|
|
msgstr ""
|
|
|
|
#. type: ifnottex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:414
|
|
msgid ""
|
|
"In the previous section, the definition of @code{for} was fixed as follows "
|
|
"to make the expansion evaluate the macro arguments the proper number of "
|
|
"times:"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:419
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro for (var from init to final do &rest body)\n"
|
|
" \"Execute a simple for loop: (for i from 1 to 10 do (print i)).\"\n"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:426
|
|
#, no-wrap
|
|
msgid ""
|
|
" `(let ((,var ,init)\n"
|
|
" (max ,final))\n"
|
|
" (while (<= ,var max)\n"
|
|
" ,@@body\n"
|
|
" (inc ,var))))\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:433
|
|
msgid ""
|
|
"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:"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:441
|
|
#, no-wrap
|
|
msgid ""
|
|
"(let ((max 0))\n"
|
|
" (for x from 0 to 10 do\n"
|
|
" (let ((this (frob x)))\n"
|
|
" (if (< max this)\n"
|
|
" (setq max this)))))\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:448
|
|
msgid ""
|
|
"The references to @code{max} inside the body of the @code{for}, which are "
|
|
"supposed to refer to the user's binding of @code{max}, really access the "
|
|
"binding made by @code{for}."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:457
|
|
msgid ""
|
|
"The way to correct this is to use an uninterned symbol instead of @code{max} "
|
|
"(@pxref{Creating Symbols}). The uninterned symbol can be bound and referred "
|
|
"to just like any other symbol, but since it is created by @code{for}, we "
|
|
"know that it cannot already appear in the user's program. Since it is not "
|
|
"interned, there is no way the user can 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:"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:468
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro for (var from init to final do &rest body)\n"
|
|
" \"Execute a simple for loop: (for i from 1 to 10 do (print i)).\"\n"
|
|
" (let ((tempvar (make-symbol \"max\")))\n"
|
|
" `(let ((,var ,init)\n"
|
|
" (,tempvar ,final))\n"
|
|
" (while (<= ,var ,tempvar)\n"
|
|
" ,@@body\n"
|
|
" (inc ,var)))))\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:475
|
|
msgid ""
|
|
"This creates an uninterned symbol named @code{max} and puts it in the "
|
|
"expansion instead of the usual interned symbol @code{max} that appears in "
|
|
"expressions ordinarily."
|
|
msgstr ""
|
|
|
|
#. type: subsection
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:477
|
|
#, no-wrap
|
|
msgid "Evaluating Macro Arguments in Expansion"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:485
|
|
msgid ""
|
|
"Another problem can happen if the macro definition itself evaluates any of "
|
|
"the macro argument expressions, such as by calling @code{eval} "
|
|
"(@pxref{Eval}). You have to take into account that macro expansion may take "
|
|
"place long before the code is executed, when the context of the caller "
|
|
"(where the macro expansion will be evaluated) is not yet accessible."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:491
|
|
msgid ""
|
|
"Also, if your macro definition does not use @code{lexical-binding}, its "
|
|
"formal arguments may hide the user's variables of the same name. Inside the "
|
|
"macro body, the macro argument binding is the most local binding of such "
|
|
"variable, so any references inside the form being evaluated do refer to it. "
|
|
"Here is an example:"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:496
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro foo (a)\n"
|
|
" (list 'setq (eval a) t))\n"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:505
|
|
#, no-wrap
|
|
msgid ""
|
|
"(setq x 'b)\n"
|
|
"(foo x) @expansion{} (setq b t)\n"
|
|
" @result{} t ; @r{and @code{b} has been set.}\n"
|
|
";; @r{but}\n"
|
|
"(setq a 'c)\n"
|
|
"(foo a) @expansion{} (setq a t)\n"
|
|
" @result{} t ; @r{but this set @code{a}, not "
|
|
"@code{c}.}\n"
|
|
"\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:512
|
|
msgid ""
|
|
"It makes a difference whether the user's variable is named @code{a} or "
|
|
"@code{x}, because @code{a} conflicts with the macro argument variable "
|
|
"@code{a}."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:517
|
|
msgid ""
|
|
"Also, the expansion of @code{(foo x)} above will return something different "
|
|
"or signal an error when the code is compiled, since in that case @code{(foo "
|
|
"x)} is expanded during compilation, whereas the execution of @code{(setq x "
|
|
"'b)} will only take place later when the code is executed."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:523
|
|
msgid ""
|
|
"To avoid these problems, @strong{don't evaluate an argument expression while "
|
|
"computing the macro expansion}. Instead, substitute the expression into the "
|
|
"macro expansion, so that its value will be computed as part of executing the "
|
|
"expansion. This is how the other examples in this chapter work."
|
|
msgstr ""
|
|
|
|
#. type: subsection
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:525
|
|
#, no-wrap
|
|
msgid "How Many Times is the Macro Expanded?"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:532
|
|
msgid ""
|
|
"Occasionally problems result from the fact that a macro call is expanded "
|
|
"each time it is evaluated in an interpreted function, but is expanded only "
|
|
"once (during compilation) for a compiled function. If the macro definition "
|
|
"has side effects, they will work differently depending on how many times the "
|
|
"macro is expanded."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:535
|
|
msgid ""
|
|
"Therefore, you should avoid side effects in computation of the macro "
|
|
"expansion, unless you really know what you are doing."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:541
|
|
msgid ""
|
|
"One special kind of side effect can't be avoided: constructing Lisp "
|
|
"objects. Almost all macro expansions include constructed lists; that is the "
|
|
"whole point of most macros. This is usually safe; there is just one case "
|
|
"where you must be careful: when the object you construct is part of a quoted "
|
|
"constant in the macro expansion."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:546
|
|
msgid ""
|
|
"If the macro is expanded just once, in compilation, then the object is "
|
|
"constructed just once, during compilation. But in interpreted execution, "
|
|
"the macro is expanded each time the macro call runs, and this means a new "
|
|
"object is constructed each time."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:552
|
|
msgid ""
|
|
"In most clean Lisp code, this difference won't matter. It can matter only "
|
|
"if you perform side-effects on the objects constructed by the macro "
|
|
"definition. Thus, to avoid trouble, @strong{avoid side effects on objects "
|
|
"constructed by macro definitions}. Here is an example of how such side "
|
|
"effects can get you into trouble:"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:557
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defmacro empty-object ()\n"
|
|
" (list 'quote (cons nil nil)))\n"
|
|
msgstr ""
|
|
|
|
#. type: group
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:565
|
|
#, no-wrap
|
|
msgid ""
|
|
"(defun initialize (condition)\n"
|
|
" (let ((object (empty-object)))\n"
|
|
" (if condition\n"
|
|
" (setcar object condition))\n"
|
|
" object))\n"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:575
|
|
msgid ""
|
|
"If @code{initialize} is interpreted, a new list @code{(nil)} is constructed "
|
|
"each time @code{initialize} is called. Thus, no side effect survives "
|
|
"between calls. If @code{initialize} is compiled, then the macro "
|
|
"@code{empty-object} is expanded during compilation, producing a single "
|
|
"constant @code{(nil)} that is reused and altered each time @code{initialize} "
|
|
"is called."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:581
|
|
msgid ""
|
|
"One way to avoid pathological cases like this is to think of "
|
|
"@code{empty-object} as a funny kind of constant, not as a memory allocation "
|
|
"construct. You wouldn't use @code{setcar} on a constant such as "
|
|
"@code{'(nil)}, so naturally you won't use it on @code{(empty-object)} "
|
|
"either."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:588
|
|
msgid ""
|
|
"Within a macro definition, you can use the @code{declare} form "
|
|
"(@pxref{Defining Macros}) to specify how @key{TAB} should indent calls to "
|
|
"the macro. An indentation specification is written like this:"
|
|
msgstr ""
|
|
|
|
#. type: example
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:591
|
|
#, no-wrap
|
|
msgid "(declare (indent @var{indent-spec}))\n"
|
|
msgstr ""
|
|
|
|
#. type: cindex
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:594
|
|
#, no-wrap
|
|
msgid "@code{lisp-indent-function} property"
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:597
|
|
msgid ""
|
|
"This results in the @code{lisp-indent-function} property being set on the "
|
|
"macro name."
|
|
msgstr ""
|
|
|
|
#. type: Plain text
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:600
|
|
msgid "Here are the possibilities for @var{indent-spec}:"
|
|
msgstr ""
|
|
|
|
#. type: code{#1}
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:602
|
|
#, no-wrap
|
|
msgid "nil"
|
|
msgstr ""
|
|
|
|
#. type: table
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:604
|
|
msgid "This is the same as no property---use the standard indentation pattern."
|
|
msgstr ""
|
|
|
|
#. type: code{#1}
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:604
|
|
#, no-wrap
|
|
msgid "defun"
|
|
msgstr ""
|
|
|
|
#. type: table
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:607
|
|
msgid ""
|
|
"Handle this function like a @samp{def} construct: treat the second line as "
|
|
"the start of a @dfn{body}."
|
|
msgstr ""
|
|
|
|
#. type: item
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:607
|
|
#, no-wrap
|
|
msgid "an integer, @var{number}"
|
|
msgstr ""
|
|
|
|
#. type: table
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:618
|
|
msgid ""
|
|
"The first @var{number} arguments of the function are @dfn{distinguished} "
|
|
"arguments; the rest are considered the body of the expression. A line in "
|
|
"the expression is indented according to whether the first argument on it is "
|
|
"distinguished or not. If the argument is part of the body, the line is "
|
|
"indented @code{lisp-body-indent} more columns than the open-parenthesis "
|
|
"starting the containing expression. If the argument is distinguished and is "
|
|
"either the first or second argument, it is indented @emph{twice} that many "
|
|
"extra columns. If the argument is distinguished and not the first or second "
|
|
"argument, the line uses the standard pattern."
|
|
msgstr ""
|
|
|
|
#. type: item
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:618
|
|
#, no-wrap
|
|
msgid "a symbol, @var{symbol}"
|
|
msgstr ""
|
|
|
|
#. type: table
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:622
|
|
msgid ""
|
|
"@var{symbol} should be a function name; that function is called to calculate "
|
|
"the indentation of a line within this expression. The function receives two "
|
|
"arguments:"
|
|
msgstr ""
|
|
|
|
#. type: var{#1}
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:624
|
|
#, no-wrap
|
|
msgid "pos"
|
|
msgstr ""
|
|
|
|
#. type: table
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:626
|
|
msgid "The position at which the line being indented begins."
|
|
msgstr ""
|
|
|
|
#. type: var{#1}
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:626
|
|
#, no-wrap
|
|
msgid "state"
|
|
msgstr ""
|
|
|
|
#. type: table
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:630
|
|
msgid ""
|
|
"The value returned by @code{parse-partial-sexp} (a Lisp primitive for "
|
|
"indentation and nesting computation) when it parses up to the beginning of "
|
|
"this line."
|
|
msgstr ""
|
|
|
|
#. type: table
|
|
#: /Users/suzume/Documents/Repositories/Projet OmegaT de Documentation Emacs -
|
|
#: Sources/doc/lispref/macros.texi:642
|
|
msgid ""
|
|
"It should return either a number, which is the number of columns of "
|
|
"indentation for that line, or a list whose car is such a number. The "
|
|
"difference between returning a number and returning a list is that a number "
|
|
"says that all following lines at the same nesting level should be indented "
|
|
"just like this one; a list says that following lines might call for "
|
|
"different indentations. This makes a difference when the indentation is "
|
|
"being computed by @kbd{C-M-q}; if the value is a number, @kbd{C-M-q} need "
|
|
"not recalculate indentation for the following lines until the end of the "
|
|
"list."
|
|
msgstr ""
|