A specification list is required for an Edebug specification if
some arguments of a macro call are evaluated while others are not. Some
elements in a specification list match one or more arguments, but others
modify the processing of all following elements. The latter, called
specification keywords, are symbols beginning with ‘&’ (such
A specification list may contain sublists, which match arguments that are themselves lists, or it may contain vectors used for grouping. Sublists and groups thus subdivide the specification list into a hierarchy of levels. Specification keywords apply only to the remainder of the sublist or group they are contained in.
When a specification list involves alternatives or repetition, matching it against an actual macro call may require backtracking. For more details, see Backtracking in Specifications.
Edebug specifications provide the power of regular expression matching, plus some context-free grammar constructs: the matching of sublists with balanced parentheses, recursive processing of forms, and recursion via indirect specifications.
Here’s a table of the possible elements of a specification list, with their meanings (see Specification Examples, for the referenced examples):
A single unevaluated Lisp object, which is not instrumented.
A single evaluated expression, which is instrumented. If your macro
wraps the expression with
lambda before it is evaluated, use
def-form instead. See
A generalized variable. See Generalized Variables.
&rest form. See
&rest below. If your macro
wraps its body of code with
lambda before it is evaluated, use
def-body instead. See
A lambda expression with no quoting.
All following elements in the specification list are optional; as soon as one does not match, Edebug stops matching at this level.
To make just a few elements optional, followed by non-optional elements,
[&optional specs…]. To specify that several
elements must all match or none, use
[specs…]. See the
All following elements in the specification list are repeated zero or more times. In the last repetition, however, it is not a problem if the expression runs out before matching all of the elements of the specification list.
To repeat only a few elements, use
To specify several elements that must all match on every repetition, use
Each of the following elements in the specification list is an
alternative. One of the alternatives must match, or the
Each list element following
&or is a single alternative. To
group two or more list elements as a single alternative, enclose them in
Each of the following elements is matched as alternatives as if by using
&or, but if any of them match, the specification fails. If none
of them match, nothing is matched, but the
Indicates that the specification is for a defining form. Edebug’s definition of a defining form is a form containing one or more code forms which are saved and executed later, after the execution of the defining form.
The defining form itself is not instrumented (that is, Edebug does not
stop before and after the defining form), but forms inside it
typically will be instrumented. The
&define keyword should be
the first element in a list specification.
This is successful when there are no more arguments to match at the current argument list level; otherwise it fails. See sublist specifications and the backquote example.
No argument is matched but backtracking through the gate is disabled
while matching the remainder of the specifications at this level. This
is primarily used to generate more specific syntax error messages. See
Backtracking in Specifications, for more details. Also see the
&error should be followed by a string, an error message, in the
edebug-spec; it aborts the instrumentation, displaying the message in
Lets a function control the parsing of the remaining code.
It takes the form
&interpose spec fun args...
and means that Edebug will first match spec against the code and
then call fun with the code that matched
spec, a parsing
function pf, and finally args.... The parsing
function expects a single argument indicating the specification list
to use to parse the remaining code. It should be called exactly once
and returns the instrumented code that fun is expected to return.
(&interpose symbolp pcase--match-pat-args) matches
sexps whose first element is a symbol and then lets
pcase--match-pat-args lookup the specs associated
with that head symbol according to
pass them to the pf it received as argument.
Any other symbol in a specification list may be a predicate or an indirect specification.
If the symbol has an Edebug specification, this indirect
specification should be either a list specification that is used in
place of the symbol, or a function that is called to process the
arguments. The specification may be defined with
Define the specification to use in place of the symbol element. specification has to be a list.
Otherwise, the symbol should be a predicate. The predicate is called
with the argument, and if the predicate returns
specification fails and the argument is not instrumented.
Some suitable predicates include
A vector of elements groups the elements into a single group specification. Its meaning has nothing to do with vectors.
The argument should be a symbol named string. This specification
is equivalent to the quoted symbol,
'symbol, where the name
of symbol is the string, but the string form is preferred.
The argument should be a vector whose elements must match the elements in the specification. See the backquote example.
Any other list is a sublist specification and the argument must be a list whose elements match the specification elements.
A sublist specification may be a dotted list and the corresponding list
argument may then be a dotted list. Alternatively, the last CDR of a
dotted list specification may be another sublist specification (via a
grouping or an indirect specification, e.g.,
(spec . [(more
specs…)])) whose elements match the non-dotted list arguments.
This is useful in recursive specifications such as in the backquote
example. Also see the description of a
above for terminating such recursion.
Note that a sublist specification written as
(specs . nil)
is equivalent to
(sublist-elements…)) is equivalent to
Here is a list of additional specifications that may appear only after
&define. See the
Extracts the name of the current defining form from the code.
It takes the form
&name [prestring] spec
[poststring] fun args... and means that Edebug will
match spec against the code and then call fun with the
concatenation of the current name, args..., prestring,
the code that matched
spec, and poststring. If fun
is absent, it defaults to a function that concatenates the arguments
@ between the previous name and the new).
The argument, a symbol, is the name of the defining form.
A defining form is not required to have a name field; and it may have multiple name fields.
The argument, a symbol, is the name of an argument of the defining form. However, lambda-list keywords (symbols starting with ‘&’) are not allowed.
This matches a lambda list—the argument list of a lambda expression.
The argument is the body of code in a definition. This is like
body, described above, but a definition body must be instrumented
with a different Edebug call that looks up information associated with
the definition. Use
def-body for the highest level list of forms
within the definition.
The argument is a single, highest-level form in a definition. This is
def-body, except it is used to match a single form rather than
a list of forms. As a special case,
def-form also means that
tracing information is not output when the form is executed. See the