aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2021-02-12 22:53:38 -0500
committerStefan Monnier2021-02-12 22:53:38 -0500
commitca0842347e5437bcaeeded4a7fd55e0e48ed4bad (patch)
tree7d9719864ae41a9a6f31e53ac4dfd8fa2a7e1416
parent626911b704b3f144e9b8dbd187c394ed90e8411c (diff)
downloademacs-ca0842347e5437bcaeeded4a7fd55e0e48ed4bad.tar.gz
emacs-ca0842347e5437bcaeeded4a7fd55e0e48ed4bad.zip
Edebug: Make it possible to debug `gv-expander`s in `declare`
Arrange for declarations to be able to specify their own specs via the `edebug-declaration-spec` property. * lisp/emacs-lisp/edebug.el: (edebug--get-declare-spec): New function. (def-declarations): New spec element. (defun, defmacro): Use it in their spec. * lisp/emacs-lisp/gv.el (gv-expander, gv-setter): Set `edebug-declaration-spec`. * test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-gv-expander): New test. * test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el (edebug-test-code-use-gv-expander): New test case.
-rw-r--r--lisp/emacs-lisp/edebug.el12
-rw-r--r--lisp/emacs-lisp/gv.el5
-rw-r--r--test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el6
-rw-r--r--test/lisp/emacs-lisp/edebug-tests.el11
4 files changed, 30 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 47b45614e71..394f47090ca 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -2207,14 +2207,12 @@ into `edebug--cl-macrolet-defs' which is checked in `edebug-list-form-args'."
2207 ;; `defun' and `defmacro' are not special forms (any more), but it's 2207 ;; `defun' and `defmacro' are not special forms (any more), but it's
2208 ;; more convenient to define their Edebug spec here. 2208 ;; more convenient to define their Edebug spec here.
2209 (defun ( &define name lambda-list lambda-doc 2209 (defun ( &define name lambda-list lambda-doc
2210 [&optional ("declare" &rest sexp)] 2210 [&optional ("declare" def-declarations)]
2211 [&optional ("interactive" &optional &or stringp def-form)] 2211 [&optional ("interactive" &optional &or stringp def-form)]
2212 def-body)) 2212 def-body))
2213 2213
2214 ;; FIXME: Improve `declare' so we can Edebug gv-expander and
2215 ;; gv-setter declarations.
2216 (defmacro ( &define name lambda-list lambda-doc 2214 (defmacro ( &define name lambda-list lambda-doc
2217 [&optional ("declare" &rest sexp)] 2215 [&optional ("declare" def-declarations)]
2218 def-body)) 2216 def-body))
2219 2217
2220 ;; function expects a symbol or a lambda or macro expression 2218 ;; function expects a symbol or a lambda or macro expression
@@ -2243,6 +2241,12 @@ into `edebug--cl-macrolet-defs' which is checked in `edebug-list-form-args'."
2243 )) 2241 ))
2244 (put name 'edebug-form-spec spec)) 2242 (put name 'edebug-form-spec spec))
2245 2243
2244(defun edebug--get-declare-spec (head)
2245 (get head 'edebug-declaration-spec))
2246
2247(def-edebug-elem-spec 'def-declarations
2248 '(&rest &or (&lookup symbolp edebug--get-declare-spec) sexp))
2249
2246(def-edebug-elem-spec 'lambda-list 2250(def-edebug-elem-spec 'lambda-list
2247 '(([&rest arg] 2251 '(([&rest arg]
2248 [&optional ["&optional" arg &rest arg]] 2252 [&optional ["&optional" arg &rest arg]]
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index c160aa1fd35..edacdf7f0c8 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -187,6 +187,11 @@ arguments as NAME. DO is a function as defined in `gv-get'."
187 (push (list 'gv-setter #'gv--setter-defun-declaration) 187 (push (list 'gv-setter #'gv--setter-defun-declaration)
188 defun-declarations-alist)) 188 defun-declarations-alist))
189 189
190;;;###autoload
191(let ((spec '(&or symbolp ("lambda" &define lambda-list def-body))))
192 (put 'gv-expander 'edebug-declaration-spec spec)
193 (put 'gv-setter 'edebug-declaration-spec spec))
194
190;; (defmacro gv-define-expand (name expander) 195;; (defmacro gv-define-expand (name expander)
191;; "Use EXPANDER to handle NAME as a generalized var. 196;; "Use EXPANDER to handle NAME as a generalized var.
192;; NAME is a symbol: the name of a function, macro, or special form. 197;; NAME is a symbol: the name of a function, macro, or special form.
diff --git a/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el b/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
index d77df3c3c51..835d3781d09 100644
--- a/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
+++ b/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
@@ -147,5 +147,11 @@
147 ;; of the same name. 147 ;; of the same name.
148 (message "Hi %s" (gate 7)))) 148 (message "Hi %s" (gate 7))))
149 149
150(defun edebug-test-code-use-gv-expander (x)
151 (declare (gv-expander
152 (lambda (do)
153 (funcall do `(car ,x) (lambda (v) `(setcar ,x ,v))))))
154 (car x))
155
150(provide 'edebug-test-code) 156(provide 'edebug-test-code)
151;;; edebug-test-code.el ends here 157;;; edebug-test-code.el ends here
diff --git a/test/lisp/emacs-lisp/edebug-tests.el b/test/lisp/emacs-lisp/edebug-tests.el
index c11bfcf0012..dfe2cb32065 100644
--- a/test/lisp/emacs-lisp/edebug-tests.el
+++ b/test/lisp/emacs-lisp/edebug-tests.el
@@ -959,6 +959,17 @@ primary ones (Bug#42671)."
959 (edebug-tests-with-normal-env 959 (edebug-tests-with-normal-env
960 (edebug-tests-setup-@ "cl-flet1" '(10) t))) 960 (edebug-tests-setup-@ "cl-flet1" '(10) t)))
961 961
962(ert-deftest edebug-tests-gv-expander ()
963 "Edebug can instrument `gv-expander' expressions."
964 (edebug-tests-with-normal-env
965 (edebug-tests-setup-@ "use-gv-expander" nil t)
966 (should (equal
967 (catch 'text
968 (run-at-time 0 nil
969 (lambda () (throw 'text (buffer-substring (point) (+ (point) 5)))))
970 (eval '(setf (edebug-test-code-use-gv-expander (cons 'a 'b)) 3) t))
971 "(func"))))
972
962(ert-deftest edebug-tests-cl-flet () 973(ert-deftest edebug-tests-cl-flet ()
963 "Check that Edebug can instrument `cl-flet' forms without name 974 "Check that Edebug can instrument `cl-flet' forms without name
964clashes (Bug#41853)." 975clashes (Bug#41853)."