;; `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
))
(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]]
(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.
;; 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
(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)."