[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master aeb25f9d3d: Teach Edebug about the special '&whole' syntax for co
From: |
Philipp Stephani |
Subject: |
master aeb25f9d3d: Teach Edebug about the special '&whole' syntax for compiler macros. |
Date: |
Thu, 3 Mar 2022 13:57:59 -0500 (EST) |
branch: master
commit aeb25f9d3d12a18ef3881e23b32a34615355d4d0
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>
Teach Edebug about the special '&whole' syntax for compiler macros.
* lisp/emacs-lisp/cl-macs.el (cl-define-compiler-macro-list): New
Edebug element specification.
(cl-define-compiler-macro): Use it.
* test/lisp/emacs-lisp/cl-macs-tests.el
(cl-define-compiler-macro/edebug): New unit test.
---
lisp/emacs-lisp/cl-macs.el | 9 ++++++++-
test/lisp/emacs-lisp/cl-macs-tests.el | 15 +++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 5085217250..accd70dc4e 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -3489,6 +3489,10 @@ omitted, a default message listing FORM itself is used."
;;; Compiler macros.
+(def-edebug-elem-spec 'cl-define-compiler-macro-list
+ `(([&optional "&whole" arg]
+ ,@(car (get 'cl-macro-list 'edebug-elem-spec)))))
+
;;;###autoload
(defmacro cl-define-compiler-macro (func args &rest body)
"Define a compiler-only macro.
@@ -3501,7 +3505,10 @@ compiler macros are expanded repeatedly until no further
expansions are
possible. Unlike regular macros, BODY can decide to \"punt\" and leave the
original function call alone by declaring an initial `&whole foo' parameter
and then returning foo."
- (declare (debug cl-defmacro) (indent 2))
+ ;; Like `cl-defmacro', but with the `&whole' special case.
+ (declare (debug (&define name cl-define-compiler-macro-list
+ cl-declarations-or-string def-body))
+ (indent 2))
(let ((p args) (res nil))
(while (consp p) (push (pop p) res))
(setq args (nconc (nreverse res) (and p (list '&rest p)))))
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el
b/test/lisp/emacs-lisp/cl-macs-tests.el
index 008ec0de4a..036ee30966 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -23,6 +23,7 @@
(require 'cl-lib)
(require 'cl-macs)
+(require 'edebug)
(require 'ert)
@@ -694,4 +695,18 @@ collection clause."
(list cl-macs--test1 cl-macs--test2))
'(1 2))))
+(ert-deftest cl-define-compiler-macro/edebug ()
+ "Check that we can instrument compiler macros."
+ (with-temp-buffer
+ (dolist (form '((defun cl-define-compiler-macro/edebug (a b) nil)
+ (cl-define-compiler-macro
+ cl-define-compiler-macro/edebug
+ (&whole w a b)
+ w)))
+ (print form (current-buffer)))
+ (let ((edebug-all-defs t)
+ (edebug-initial-mode 'Go-nonstop))
+ ;; Just make sure the forms can be instrumented.
+ (eval-buffer))))
+
;;; cl-macs-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master aeb25f9d3d: Teach Edebug about the special '&whole' syntax for compiler macros.,
Philipp Stephani <=