aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2021-02-12 22:53:38 -0500
committerStefan Monnier2021-02-12 22:53:38 -0500
commitca0842347e5437bcaeeded4a7fd55e0e48ed4bad (patch)
tree7d9719864ae41a9a6f31e53ac4dfd8fa2a7e1416 /lisp
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/edebug.el12
-rw-r--r--lisp/emacs-lisp/gv.el5
2 files changed, 13 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.