Suggested by Drew Adams (Bug#31311).
* lisp/emacs-lisp/cl-macs.el (cl-struct): ...here.
* lisp/emacs-lisp/eieio.el (eieio): Likewise.
* lisp/emacs-lisp/radix-tree.el (radix-tree-leaf): Likewise.
* lisp/emacs-lisp/rx.el (rx): Likewise.
;;;###autoload
(pcase-defmacro cl-struct (type &rest fields)
- "Pcase patterns to match cl-structs.
-Elements of FIELDS can be of the form (NAME PAT) in which case the contents of
-field NAME is matched against PAT, or they can be of the form NAME which
-is a shorthand for (NAME NAME)."
+ "Pcase patterns that match cl-struct EXPVAL of type TYPE.
+Elements of FIELDS can be of the form (NAME PAT) in which case the
+contents of field NAME is matched against PAT, or they can be of
+the form NAME which is a shorthand for (NAME NAME)."
(declare (debug (sexp &rest [&or (sexp pcase-PAT) sexp])))
`(and (pred (pcase--flip cl-typep ',type))
,@(mapcar
index))))
(pcase-defmacro eieio (&rest fields)
- "Pcase patterns to match EIEIO objects.
-Elements of FIELDS can be of the form (NAME PAT) in which case the contents of
-field NAME is matched against PAT, or they can be of the form NAME which
-is a shorthand for (NAME NAME)."
+ "Pcase patterns that match EIEIO object EXPVAL.
+Elements of FIELDS can be of the form (NAME PAT) in which case the
+contents of field NAME is matched against PAT, or they can be of
+ the form NAME which is a shorthand for (NAME NAME)."
(declare (debug (&rest [&or (sexp pcase-PAT) sexp])))
(let ((is (make-symbol "table")))
;; FIXME: This generates a horrendous mess of redundant let bindings.
(eval-and-compile
(pcase-defmacro radix-tree-leaf (vpat)
+ "Build a `pcase' pattern that matches radix-tree leaf EXPVAL.
+VPAT is a `pcase' pattern to extract the value."
;; FIXME: We'd like to use a negative pattern (not consp), but pcase
;; doesn't support it. Using `atom' works but generates sub-optimal code.
`(or `(t . ,,vpat) (and (pred atom) ,vpat))))
(pcase-defmacro rx (&rest regexps)
"Build a `pcase' pattern matching `rx' regexps.
The REGEXPS are interpreted as by `rx'. The pattern matches if
-the regular expression so constructed matches the object, as if
+the regular expression so constructed matches EXPVAL, as if
by `string-match'.
In addition to the usual `rx' constructs, REGEXPS can contain the