summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2020-06-14 18:18:13 +0200
committerPhilipp Stephani <phst@google.com>2020-06-14 18:18:13 +0200
commit62cf8f1649468fc2f6c4f8926ab5c4bb184bfbe8 (patch)
tree8d5f6bf7b9d21548712f3638ebe895a36424be54
parentb3e7d046c3a94556fcaf6f9ce72aa2ecb20262a6 (diff)
downloademacs-62cf8f1649468fc2f6c4f8926ab5c4bb184bfbe8.tar.gz
emacs-62cf8f1649468fc2f6c4f8926ab5c4bb184bfbe8.tar.bz2
emacs-62cf8f1649468fc2f6c4f8926ab5c4bb184bfbe8.zip
Ensure that getters and setters can be edebugged at the same time.
It's necessary to add a name suffix to setters defined with 'gv-define-setter' so that Edebug can distinguish between the getter and the setter (Bug#41853). * lisp/emacs-lisp/gv.el (gv-define-setter): Add a name suffix to setter definitions. * test/lisp/emacs-lisp/gv-tests.el (gv-setter-edebug): New regression test.
-rw-r--r--lisp/emacs-lisp/gv.el2
-rw-r--r--test/lisp/emacs-lisp/gv-tests.el19
2 files changed, 20 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index 096036a0ffa..513bd328899 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -224,7 +224,7 @@ The first arg in ARGLIST (the one that receives VAL) receives an expression
which can do arbitrary things, whereas the other arguments are all guaranteed
to be pure and copyable. Example use:
(gv-define-setter aref (v a i) \\=`(aset ,a ,i ,v))"
- (declare (indent 2) (debug (&define name sexp def-body)))
+ (declare (indent 2) (debug (&define name :name gv-setter sexp def-body)))
`(gv-define-expander ,name
(lambda (do &rest args)
(declare-function
diff --git a/test/lisp/emacs-lisp/gv-tests.el b/test/lisp/emacs-lisp/gv-tests.el
index 7fa4cd50b08..7a8402be074 100644
--- a/test/lisp/emacs-lisp/gv-tests.el
+++ b/test/lisp/emacs-lisp/gv-tests.el
@@ -19,6 +19,7 @@
;;; Code:
+(require 'edebug)
(require 'ert)
(eval-when-compile (require 'cl-lib))
@@ -137,6 +138,24 @@
(should (equal (buffer-string)
"Symbol's function definition is void: \\(setf\\ gv-test-foo\\)\n")))))
+(ert-deftest gv-setter-edebug ()
+ "Check that a setter can be defined and edebugged together with
+its getter (Bug#41853)."
+ (with-temp-buffer
+ (let ((edebug-all-defs t)
+ (edebug-initial-mode 'Go-nonstop))
+ (dolist (form '((defun gv-setter-edebug-help (b) b)
+ (defun gv-setter-edebug-get (a b)
+ (get a (gv-setter-edebug-help b)))
+ (gv-define-setter gv-setter-edebug-get (x a b)
+ `(setf (get ,a (gv-setter-edebug-help ,b)) ,x))
+ (push 123 (gv-setter-edebug-get 'gv-setter-edebug
+ 'gv-setter-edebug-prop))))
+ (print form (current-buffer)))
+ ;; Only check whether evaluation works in general.
+ (eval-buffer)))
+ (should (equal (get 'gv-setter-edebug 'gv-setter-edebug-prop) '(123))))
+
;; `ert-deftest' messes up macroexpansion when the test file itself is
;; compiled (see Bug #24402).