mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 20:32:00 -08:00
Edebug: Make it possible to debug gv-expanders 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.
This commit is contained in:
parent
626911b704
commit
ca0842347e
4 changed files with 30 additions and 4 deletions
|
|
@ -2207,14 +2207,12 @@ into `edebug--cl-macrolet-defs' which is checked in `edebug-list-form-args'."
|
|||
;; `defun' and `defmacro' are not special forms (any more), but it's
|
||||
;; more convenient to define their Edebug spec here.
|
||||
(defun ( &define name lambda-list lambda-doc
|
||||
[&optional ("declare" &rest sexp)]
|
||||
[&optional ("declare" def-declarations)]
|
||||
[&optional ("interactive" &optional &or stringp def-form)]
|
||||
def-body))
|
||||
|
||||
;; FIXME: Improve `declare' so we can Edebug gv-expander and
|
||||
;; gv-setter declarations.
|
||||
(defmacro ( &define name lambda-list lambda-doc
|
||||
[&optional ("declare" &rest sexp)]
|
||||
[&optional ("declare" def-declarations)]
|
||||
def-body))
|
||||
|
||||
;; 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'."
|
|||
))
|
||||
(put name 'edebug-form-spec spec))
|
||||
|
||||
(defun edebug--get-declare-spec (head)
|
||||
(get head 'edebug-declaration-spec))
|
||||
|
||||
(def-edebug-elem-spec 'def-declarations
|
||||
'(&rest &or (&lookup symbolp edebug--get-declare-spec) sexp))
|
||||
|
||||
(def-edebug-elem-spec 'lambda-list
|
||||
'(([&rest arg]
|
||||
[&optional ["&optional" arg &rest arg]]
|
||||
|
|
|
|||
|
|
@ -187,6 +187,11 @@ arguments as NAME. DO is a function as defined in `gv-get'."
|
|||
(push (list 'gv-setter #'gv--setter-defun-declaration)
|
||||
defun-declarations-alist))
|
||||
|
||||
;;;###autoload
|
||||
(let ((spec '(&or symbolp ("lambda" &define lambda-list def-body))))
|
||||
(put 'gv-expander 'edebug-declaration-spec spec)
|
||||
(put 'gv-setter 'edebug-declaration-spec spec))
|
||||
|
||||
;; (defmacro gv-define-expand (name expander)
|
||||
;; "Use EXPANDER to handle NAME as a generalized var.
|
||||
;; NAME is a symbol: the name of a function, macro, or special form.
|
||||
|
|
|
|||
|
|
@ -147,5 +147,11 @@
|
|||
;; of the same name.
|
||||
(message "Hi %s" (gate 7))))
|
||||
|
||||
(defun edebug-test-code-use-gv-expander (x)
|
||||
(declare (gv-expander
|
||||
(lambda (do)
|
||||
(funcall do `(car ,x) (lambda (v) `(setcar ,x ,v))))))
|
||||
(car x))
|
||||
|
||||
(provide 'edebug-test-code)
|
||||
;;; edebug-test-code.el ends here
|
||||
|
|
|
|||
|
|
@ -959,6 +959,17 @@ primary ones (Bug#42671)."
|
|||
(edebug-tests-with-normal-env
|
||||
(edebug-tests-setup-@ "cl-flet1" '(10) t)))
|
||||
|
||||
(ert-deftest edebug-tests-gv-expander ()
|
||||
"Edebug can instrument `gv-expander' expressions."
|
||||
(edebug-tests-with-normal-env
|
||||
(edebug-tests-setup-@ "use-gv-expander" nil t)
|
||||
(should (equal
|
||||
(catch 'text
|
||||
(run-at-time 0 nil
|
||||
(lambda () (throw 'text (buffer-substring (point) (+ (point) 5)))))
|
||||
(eval '(setf (edebug-test-code-use-gv-expander (cons 'a 'b)) 3) t))
|
||||
"(func"))))
|
||||
|
||||
(ert-deftest edebug-tests-cl-flet ()
|
||||
"Check that Edebug can instrument `cl-flet' forms without name
|
||||
clashes (Bug#41853)."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue