diff options
| author | Philipp Stephani | 2022-03-03 19:56:09 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2022-03-03 19:57:00 +0100 |
| commit | aeb25f9d3d12a18ef3881e23b32a34615355d4d0 (patch) | |
| tree | fb5dd277fb3bd36e5d807557962910ab3aacdca0 | |
| parent | dc8a692f97fdafaa31001ab0620394525103ddb7 (diff) | |
| download | emacs-aeb25f9d3d12a18ef3881e23b32a34615355d4d0.tar.gz emacs-aeb25f9d3d12a18ef3881e23b32a34615355d4d0.zip | |
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.
| -rw-r--r-- | lisp/emacs-lisp/cl-macs.el | 9 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 15 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 50852172505..accd70dc4ef 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." | |||
| 3489 | 3489 | ||
| 3490 | ;;; Compiler macros. | 3490 | ;;; Compiler macros. |
| 3491 | 3491 | ||
| 3492 | (def-edebug-elem-spec 'cl-define-compiler-macro-list | ||
| 3493 | `(([&optional "&whole" arg] | ||
| 3494 | ,@(car (get 'cl-macro-list 'edebug-elem-spec))))) | ||
| 3495 | |||
| 3492 | ;;;###autoload | 3496 | ;;;###autoload |
| 3493 | (defmacro cl-define-compiler-macro (func args &rest body) | 3497 | (defmacro cl-define-compiler-macro (func args &rest body) |
| 3494 | "Define a compiler-only macro. | 3498 | "Define a compiler-only macro. |
| @@ -3501,7 +3505,10 @@ compiler macros are expanded repeatedly until no further expansions are | |||
| 3501 | possible. Unlike regular macros, BODY can decide to \"punt\" and leave the | 3505 | possible. Unlike regular macros, BODY can decide to \"punt\" and leave the |
| 3502 | original function call alone by declaring an initial `&whole foo' parameter | 3506 | original function call alone by declaring an initial `&whole foo' parameter |
| 3503 | and then returning foo." | 3507 | and then returning foo." |
| 3504 | (declare (debug cl-defmacro) (indent 2)) | 3508 | ;; Like `cl-defmacro', but with the `&whole' special case. |
| 3509 | (declare (debug (&define name cl-define-compiler-macro-list | ||
| 3510 | cl-declarations-or-string def-body)) | ||
| 3511 | (indent 2)) | ||
| 3505 | (let ((p args) (res nil)) | 3512 | (let ((p args) (res nil)) |
| 3506 | (while (consp p) (push (pop p) res)) | 3513 | (while (consp p) (push (pop p) res)) |
| 3507 | (setq args (nconc (nreverse res) (and p (list '&rest p))))) | 3514 | (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 008ec0de4a6..036ee30966b 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | (require 'cl-lib) | 24 | (require 'cl-lib) |
| 25 | (require 'cl-macs) | 25 | (require 'cl-macs) |
| 26 | (require 'edebug) | ||
| 26 | (require 'ert) | 27 | (require 'ert) |
| 27 | 28 | ||
| 28 | 29 | ||
| @@ -694,4 +695,18 @@ collection clause." | |||
| 694 | (list cl-macs--test1 cl-macs--test2)) | 695 | (list cl-macs--test1 cl-macs--test2)) |
| 695 | '(1 2)))) | 696 | '(1 2)))) |
| 696 | 697 | ||
| 698 | (ert-deftest cl-define-compiler-macro/edebug () | ||
| 699 | "Check that we can instrument compiler macros." | ||
| 700 | (with-temp-buffer | ||
| 701 | (dolist (form '((defun cl-define-compiler-macro/edebug (a b) nil) | ||
| 702 | (cl-define-compiler-macro | ||
| 703 | cl-define-compiler-macro/edebug | ||
| 704 | (&whole w a b) | ||
| 705 | w))) | ||
| 706 | (print form (current-buffer))) | ||
| 707 | (let ((edebug-all-defs t) | ||
| 708 | (edebug-initial-mode 'Go-nonstop)) | ||
| 709 | ;; Just make sure the forms can be instrumented. | ||
| 710 | (eval-buffer)))) | ||
| 711 | |||
| 697 | ;;; cl-macs-tests.el ends here | 712 | ;;; cl-macs-tests.el ends here |