Function: match*
match* is an autoloaded macro defined in cond-star.el.gz.
Signature
(match* PATTERN DATUM)
Documentation
This specifies matching DATUM against PATTERN.
This is not really a Lisp operator; it is meaningful only in the
CONDITION of a cond* clause.
_ matches any value.
KEYWORD matches that keyword.
nil matches nil.
t matches t.
SYMBOL matches any value and binds SYMBOL to that value.
If SYMBOL has been matched and bound earlier in this pattern,
it matches here the same value that it matched before.
REGEXP matches a string if REGEXP matches it.
The match must cover the entire string from its first char to its last.
ATOM (meaning any other kind of non-list not described above)
matches anything equal to it.
(rx REGEXP) uses a regexp specified in s-expression form,
as in the function rx, and matches the data that way.
(rx REGEXP SYM0 SYM1...) uses a regexp specified in s-expression form,
and binds the symbols SYM0, SYM1, and so on
to (match-string 0 DATUM), (match-string 1 DATUM), and so on.
You can use as many SYMs as regexp matching supports.
`OBJECT matches any value equal to OBJECT.
(cons CARPAT CDRPAT)
matches a cons cell if CARPAT matches its car and CDRPAT matches its cdr.
(list ELTPATS...)
matches a list if the ELTPATS match its elements.
The first ELTPAT should match the list's first element.
The second ELTPAT should match the list's second element. And so on.
(vector ELTPATS...)
matches a vector if the ELTPATS match its elements.
The first ELTPAT should match the vector's first element.
The second ELTPAT should match the vector's second element. And so on.
(cdr PATTERN) matches PATTERN with strict checking of cdrs.
That means that list patterns verify that the final cdr is nil.
Strict checking is the default.
(cdr-ignore PATTERN) matches PATTERN with lax checking of cdrs.
That means that list patterns do not examine the final cdr.
(and CONJUNCTS...) matches each of the CONJUNCTS against the same data.
If all of them match, this pattern succeeds.
If one CONJUNCT fails, this pattern fails and does not try more CONJUNCTS.
(or DISJUNCTS...) matches each of the DISJUNCTS against the same data.
If one DISJUNCT succeeds, this pattern succeeds
and does not try more DISJUNCTs.
If all of them fail, this pattern fails.
(COND*-EXPANDER ...)
Here the car is a symbol that has a cond*-expander property
which defines how to handle it in a pattern. The property value
is a function. Trying to match such a pattern calls that
function with one argument, the pattern in question (including its car).
The function should return an equivalent pattern
to be matched instead.
(PREDICATE SYMBOL)
matches datum if (PREDICATE DATUM) is true,
then binds SYMBOL to DATUM.
(PREDICATE SYMBOL MORE-ARGS...)
matches datum if (PREDICATE DATUM MORE-ARGS...) is true,
then binds SYMBOL to DATUM.
MORE-ARGS... can refer to symbols bound earlier in the pattern.
(constrain SYMBOL EXP)
matches datum if the form EXP is true.
EXP can refer to symbols bound earlier in the pattern.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cond-star.el.gz
;; The following four macros are autoloaded for the sake of syntax
;; highlighting.
;;;###autoload
(defmacro match* (_pattern _datum)
"This specifies matching DATUM against PATTERN.
This is not really a Lisp operator; it is meaningful only in the
CONDITION of a `cond*' clause.
`_' matches any value.
KEYWORD matches that keyword.
nil matches nil.
t matches t.
SYMBOL matches any value and binds SYMBOL to that value.
If SYMBOL has been matched and bound earlier in this pattern,
it matches here the same value that it matched before.
REGEXP matches a string if REGEXP matches it.
The match must cover the entire string from its first char to its last.
ATOM (meaning any other kind of non-list not described above)
matches anything `equal' to it.
\(rx REGEXP) uses a regexp specified in s-expression form,
as in the function `rx', and matches the data that way.
\(rx REGEXP SYM0 SYM1...) uses a regexp specified in s-expression form,
and binds the symbols SYM0, SYM1, and so on
to (match-string 0 DATUM), (match-string 1 DATUM), and so on.
You can use as many SYMs as regexp matching supports.
\\=`OBJECT matches any value `equal' to OBJECT.
\(cons CARPAT CDRPAT)
matches a cons cell if CARPAT matches its car and CDRPAT matches its cdr.
\(list ELTPATS...)
matches a list if the ELTPATS match its elements.
The first ELTPAT should match the list's first element.
The second ELTPAT should match the list's second element. And so on.
\(vector ELTPATS...)
matches a vector if the ELTPATS match its elements.
The first ELTPAT should match the vector's first element.
The second ELTPAT should match the vector's second element. And so on.
\(cdr PATTERN) matches PATTERN with strict checking of cdrs.
That means that `list' patterns verify that the final cdr is nil.
Strict checking is the default.
\(cdr-ignore PATTERN) matches PATTERN with lax checking of cdrs.
That means that `list' patterns do not examine the final cdr.
\(and CONJUNCTS...) matches each of the CONJUNCTS against the same data.
If all of them match, this pattern succeeds.
If one CONJUNCT fails, this pattern fails and does not try more CONJUNCTS.
\(or DISJUNCTS...) matches each of the DISJUNCTS against the same data.
If one DISJUNCT succeeds, this pattern succeeds
and does not try more DISJUNCTs.
If all of them fail, this pattern fails.
\(COND*-EXPANDER ...)
Here the car is a symbol that has a `cond*-expander' property
which defines how to handle it in a pattern. The property value
is a function. Trying to match such a pattern calls that
function with one argument, the pattern in question (including its car).
The function should return an equivalent pattern
to be matched instead.
\(PREDICATE SYMBOL)
matches datum if (PREDICATE DATUM) is true,
then binds SYMBOL to DATUM.
\(PREDICATE SYMBOL MORE-ARGS...)
matches datum if (PREDICATE DATUM MORE-ARGS...) is true,
then binds SYMBOL to DATUM.
MORE-ARGS... can refer to symbols bound earlier in the pattern.
\(constrain SYMBOL EXP)
matches datum if the form EXP is true.
EXP can refer to symbols bound earlier in the pattern."
(macroexp-warn-and-return "`match*' used other than as a `cond*' condition"
nil 'suspicious))