aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/edebug.texi23
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/emacs-lisp/edebug.el37
-rw-r--r--lisp/emacs-lisp/testcover.el23
4 files changed, 40 insertions, 49 deletions
diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi
index 94d61480f10..651bfacb4cf 100644
--- a/doc/lispref/edebug.texi
+++ b/doc/lispref/edebug.texi
@@ -1705,23 +1705,18 @@ instrumented definition to the key of the new entry, and Edebug will
1705call the new functions in place of its own for that definition. 1705call the new functions in place of its own for that definition.
1706@end defopt 1706@end defopt
1707 1707
1708@defopt edebug-new-definition-functions 1708@defopt edebug-new-definition-function
1709An abnormal hook run by Edebug after it wraps the body of a definition 1709A function run by Edebug after it wraps the body of a definition
1710or closure. After Edebug has initialized its own data, each function 1710or closure. After Edebug has initialized its own data, this function
1711is called with one argument, the symbol associated with the 1711is called with one argument, the symbol associated with the
1712definition, which may be the actual symbol defined or one generated by 1712definition, which may be the actual symbol defined or one generated by
1713Edebug. This hook may be used to set the @code{edebug-behavior} 1713Edebug. This function may be used to set the @code{edebug-behavior}
1714symbol property of each definition instrumented by Edebug. 1714symbol property of each definition instrumented by Edebug.
1715
1716By default @code{edebug-new-definition-functions} contains
1717@code{edebug-announce-definition} which prints a message each time a
1718definition is instrumented. If you are instrumenting a lot of code
1719and find the messages excessive, remove
1720@code{edebug-announce-definition}.
1721@end defopt 1715@end defopt
1722 1716
1723@defopt edebug-after-instrumentation-functions 1717@defopt edebug-after-instrumentation-function
1724An abnormal hook run by Edebug after it instruments a form. 1718To inspect or modify Edebug's instrumentation before it is used, set
1725Each function is called with one argument, a form which has 1719this variable to a function which takes one argument, an instrumented
1726just been instrumented by Edebug. 1720top-level form, and returns either the same or a replacement form,
1721which Edebug will then use as the final result of instrumentation.
1727@end defopt 1722@end defopt
diff --git a/etc/NEWS b/etc/NEWS
index 267d9883927..5c6c0b7f2a0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -71,9 +71,9 @@ directories in the destination.
71 71
72+++ 72+++
73*** The runtime behavior of Edebug's instrumentation can be changed 73*** The runtime behavior of Edebug's instrumentation can be changed
74using the new variable 'edebug-behavior-alist' and the new abnormal 74using the new variables 'edebug-behavior-alist',
75hooks 'edebug-after-instrumentation-functions' and 75'edebug-after-instrumentation-function' and
76'edebug-new-definition-functions'. Edebug's behavior can be changed 76'edebug-new-definition-function'. Edebug's behavior can be changed
77globally or for individual definitions. 77globally or for individual definitions.
78 78
79** Enhanced xterm support 79** Enhanced xterm support
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)