aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorGemini Lasswell2017-10-14 09:13:36 -0700
committerGemini Lasswell2017-10-22 10:47:50 -0700
commite07cf691decf01dc3cbe19a413708570b95bc41b (patch)
tree0500a27e83dcef7fdf5bb846562e9d92c67fbf58 /lisp
parent9c8f8de0f3e00d4f862fa5c17e3b46fcd23e5f7f (diff)
downloademacs-e07cf691decf01dc3cbe19a413708570b95bc41b.tar.gz
emacs-e07cf691decf01dc3cbe19a413708570b95bc41b.zip
Change Edebug's behavior-changing hooks to variables
* lisp/emacs-lisp/edebug.el (edebug-after-instrumentation-functions) (edebug-new-definition-functions): Deleted. (edebug-after-instrumentation-function) (edebug-new-definition-function): New variables. (edebug-behavior-alist): Update docstring. (edebug-read-and-maybe-wrap-form1, edebug-make-form-wrapper): Use new variables. * lisp/emacs-lisp/testcover.el (testcover-start) (testcover-this-defun): Use `edebug-after-instrumentation-function' and `edebug-new-definition-function'. (testcover-after-instrumentation): Return passed form. (testcover-init-definition): Use argument instead of `edebug-def-name'. * doc/lispref/edebug.texi (Edebug Options): Replace descriptions of `edebug-after-instrumentation-functions' and `edebug-new-definition-functions' with `edebug-after-instrumentation-function' and `edebug-new-definition-function'.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/edebug.el37
-rw-r--r--lisp/emacs-lisp/testcover.el23
2 files changed, 28 insertions, 32 deletions
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 77523de32c5..0e8f77e29a8 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -1065,16 +1065,17 @@ circular objects. Let `read' read everything else."
1065(defvar edebug-error-point nil) 1065(defvar edebug-error-point nil)
1066(defvar edebug-best-error nil) 1066(defvar edebug-best-error nil)
1067 1067
1068;; Hooks which may be used to extend Edebug's functionality. See 1068;; Functions which may be used to extend Edebug's functionality. See
1069;; Testcover for an example. 1069;; Testcover for an example.
1070(defvar edebug-after-instrumentation-functions nil 1070(defvar edebug-after-instrumentation-function #'identity
1071 "Abnormal hook run on code after instrumentation for debugging. 1071 "Function to run on code after instrumentation for debugging.
1072Each function is called with one argument, a form which has just 1072The function is called with one argument, a FORM which has just
1073been instrumented for Edebugging.") 1073been instrumented for Edebugging, and it should return either FORM
1074 1074or a replacement form to use in its place.")
1075(defvar edebug-new-definition-functions '(edebug-announce-definition) 1075
1076 "Abnormal hook run after Edebug wraps a new definition. 1076(defvar edebug-new-definition-function #'edebug-new-definition
1077After Edebug has initialized its own data, each hook function is 1077 "Function to call after Edebug wraps a new definition.
1078After Edebug has initialized its own data, this function is
1078called with one argument, the symbol associated with the 1079called with one argument, the symbol associated with the
1079definition, which may be the actual symbol defined or one 1080definition, which may be the actual symbol defined or one
1080generated by Edebug.") 1081generated by Edebug.")
@@ -1087,9 +1088,9 @@ Each definition instrumented by Edebug will have a
1087the instrumented code is running, Edebug will look here for the 1088the instrumented code is running, Edebug will look here for the
1088implementations of `edebug-enter', `edebug-before', and 1089implementations of `edebug-enter', `edebug-before', and
1089`edebug-after'. Edebug's instrumentation may be used for a new 1090`edebug-after'. Edebug's instrumentation may be used for a new
1090purpose by adding an entry to this alist and a hook to 1091purpose by adding an entry to this alist, and setting
1091`edebug-new-definition-functions' which sets `edebug-behavior' 1092`edebug-new-definition-function' to a function which sets
1092for the definition.") 1093`edebug-behavior' for the definition.")
1093 1094
1094(defun edebug-read-and-maybe-wrap-form () 1095(defun edebug-read-and-maybe-wrap-form ()
1095 ;; Read a form and wrap it with edebug calls, if the conditions are right. 1096 ;; Read a form and wrap it with edebug calls, if the conditions are right.
@@ -1189,8 +1190,7 @@ for the definition.")
1189 1190
1190 ;; Not a defining form, and not edebugging. 1191 ;; Not a defining form, and not edebugging.
1191 (t (edebug-read-sexp))))) 1192 (t (edebug-read-sexp)))))
1192 (run-hook-with-args 'edebug-after-instrumentation-functions result) 1193 (funcall edebug-after-instrumentation-function result))))
1193 result)))
1194 1194
1195(defvar edebug-def-args) ; args of defining form. 1195(defvar edebug-def-args) ; args of defining form.
1196(defvar edebug-def-interactive) ; is it an emacs interactive function? 1196(defvar edebug-def-interactive) ; is it an emacs interactive function?
@@ -1383,13 +1383,14 @@ expressions; a `progn' form will be returned enclosing these forms."
1383 edebug-offset-list 1383 edebug-offset-list
1384 edebug-top-window-data 1384 edebug-top-window-data
1385 )) 1385 ))
1386 (put edebug-def-name 'edebug-behavior 'edebug) 1386
1387 (run-hook-with-args 'edebug-new-definition-functions edebug-def-name) 1387 (funcall edebug-new-definition-function edebug-def-name)
1388 result 1388 result
1389 ))) 1389 )))
1390 1390
1391(defun edebug-announce-definition (def-name) 1391(defun edebug-new-definition (def-name)
1392 "Announce Edebug's processing of DEF-NAME." 1392 "Set up DEF-NAME to use Edebug's instrumentation functions."
1393 (put def-name 'edebug-behavior 'edebug)
1393 (message "Edebug: %s" def-name)) 1394 (message "Edebug: %s" def-name))
1394 1395
1395 1396
diff --git a/lisp/emacs-lisp/testcover.el b/lisp/emacs-lisp/testcover.el
index 3628968974c..797cc682171 100644
--- a/lisp/emacs-lisp/testcover.el
+++ b/lisp/emacs-lisp/testcover.el
@@ -193,12 +193,9 @@ If BYTE-COMPILE is non-nil, byte compile each function after instrumenting."
193 testcover-module-constants nil 193 testcover-module-constants nil
194 testcover-module-1value-functions nil 194 testcover-module-1value-functions nil
195 testcover-module-potentially-1value-functions nil) 195 testcover-module-potentially-1value-functions nil)
196 (cl-letf ((edebug-all-defs t) 196 (let ((edebug-all-defs t)
197 (edebug-after-instrumentation-functions) 197 (edebug-after-instrumentation-function #'testcover-after-instrumentation)
198 (edebug-new-definition-functions)) 198 (edebug-new-definition-function #'testcover-init-definition))
199 (add-hook 'edebug-after-instrumentation-functions 'testcover-after-instrumentation)
200 (add-hook 'edebug-new-definition-functions 'testcover-init-definition)
201 (remove-hook 'edebug-new-definition-functions 'edebug-announce-definition)
202 (eval-buffer buf))) 199 (eval-buffer buf)))
203 (when byte-compile 200 (when byte-compile
204 (dolist (x (reverse edebug-form-data)) 201 (dolist (x (reverse edebug-form-data))
@@ -210,12 +207,9 @@ If BYTE-COMPILE is non-nil, byte compile each function after instrumenting."
210(defun testcover-this-defun () 207(defun testcover-this-defun ()
211 "Start coverage on function under point." 208 "Start coverage on function under point."
212 (interactive) 209 (interactive)
213 (cl-letf ((edebug-all-defs t) 210 (let ((edebug-all-defs t)
214 (edebug-after-instrumentation-functions) 211 (edebug-after-instrumentation-function #'testcover-after-instrumentation)
215 (edebug-new-definition-functions)) 212 (edebug-new-definition-function #'testcover-init-definition))
216 (add-hook 'edebug-after-instrumentation-functions 'testcover-after-instrumentation)
217 (add-hook 'edebug-new-definition-functions 'testcover-init-definition)
218 (remove-hook 'edebug-new-definition-functions 'edebug-announce-definition)
219 (eval-defun nil))) 213 (eval-defun nil)))
220 214
221(defun testcover-end (filename) 215(defun testcover-end (filename)
@@ -231,11 +225,12 @@ If BYTE-COMPILE is non-nil, byte compile each function after instrumenting."
231 225
232(defun testcover-after-instrumentation (form) 226(defun testcover-after-instrumentation (form)
233 "Analyze FORM for code coverage." 227 "Analyze FORM for code coverage."
234 (testcover-analyze-coverage form)) 228 (testcover-analyze-coverage form)
229 form)
235 230
236(defun testcover-init-definition (sym) 231(defun testcover-init-definition (sym)
237 "Mark SYM as under test coverage." 232 "Mark SYM as under test coverage."
238 (message "Testcover: %s" edebug-def-name) 233 (message "Testcover: %s" sym)
239 (put sym 'edebug-behavior 'testcover)) 234 (put sym 'edebug-behavior 'testcover))
240 235
241(defun testcover-enter (func _args body) 236(defun testcover-enter (func _args body)