emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r108553: * lisp/emacs-lisp/pcase.el (


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108553: * lisp/emacs-lisp/pcase.el (pcase-UPAT, pcase-QPAT): New edebug specs.
Date: Sun, 10 Jun 2012 20:46:21 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108553
author: Johan Bockgård <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Sun 2012-06-10 20:46:21 -0400
message:
  * lisp/emacs-lisp/pcase.el (pcase-UPAT, pcase-QPAT): New edebug specs.
  (pcase, pcase-let*, pcase-dolist): Use them.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/pcase.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-06-11 00:33:33 +0000
+++ b/lisp/ChangeLog    2012-06-11 00:46:21 +0000
@@ -1,3 +1,8 @@
+2012-06-11  Johan Bockgård  <address@hidden>
+
+       * emacs-lisp/pcase.el (pcase-UPAT, pcase-QPAT): New edebug specs.
+       (pcase, pcase-let*, pcase-dolist): Use them.
+
 2012-06-11  Stefan Monnier  <address@hidden>
 
        * emacs-lisp/pcase.el (pcase--let*): New function.

=== modified file 'lisp/emacs-lisp/pcase.el'
--- a/lisp/emacs-lisp/pcase.el  2012-06-11 00:33:33 +0000
+++ b/lisp/emacs-lisp/pcase.el  2012-06-11 00:46:21 +0000
@@ -66,6 +66,27 @@
 
 (defconst pcase--dontcare-upats '(t _ dontcare))
 
+(def-edebug-spec
+  pcase-UPAT
+  (&or symbolp
+       ("or" &rest pcase-UPAT)
+       ("and" &rest pcase-UPAT)
+       ("`" pcase-QPAT)
+       ("guard" form)
+       ("let" pcase-UPAT form)
+       ("pred"
+        &or lambda-expr
+        ;; Punt on macros/special forms.
+        (functionp &rest form)
+        sexp)
+       sexp))
+
+(def-edebug-spec
+  pcase-QPAT
+  (&or ("," pcase-UPAT)
+       (pcase-QPAT . pcase-QPAT)
+       sexp))
+
 ;;;###autoload
 (defmacro pcase (exp &rest cases)
   "Perform ML-style pattern matching on EXP.
@@ -98,7 +119,7 @@
 E.g. you can match pairs where the cdr is larger than the car with a pattern
 like `(,a . ,(pred (< a))) or, with more checks:
 `(,(and a (pred numberp)) . ,(and (pred numberp) (pred (< a))))"
-  (declare (indent 1) (debug cl-case))  ;FIXME: edebug `guard' and vars.
+  (declare (indent 1) (debug (form &rest (pcase-UPAT body))))
   ;; We want to use a weak hash table as a cache, but the key will unavoidably
   ;; be based on `exp' and `cases', yet `cases' is a fresh new list each time
   ;; we're called so it'll be immediately GC'd.  So we use (car cases) as key
@@ -144,7 +165,7 @@
 BODY should be an expression, and BINDINGS should be a list of bindings
 of the form (UPAT EXP)."
   (declare (indent 1)
-           (debug ((&rest (sexp &optional form)) body)))
+           (debug ((&rest (pcase-UPAT &optional form)) body)))
   (let ((cached (gethash bindings pcase--memoize)))
     ;; cached = (BODY . EXPANSION)
     (if (equal (car cached) body)
@@ -174,7 +195,7 @@
       `(let ,(nreverse bindings) (pcase-let* ,matches ,@body)))))
 
 (defmacro pcase-dolist (spec &rest body)
-  (declare (indent 1))
+  (declare (indent 1) (debug ((pcase-UPAT form) body)))
   (if (pcase--trivial-upat-p (car spec))
       `(dolist ,spec ,@body)
     (let ((tmpvar (make-symbol "x")))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]