diff options
| author | Gemini Lasswell | 2017-10-14 09:13:36 -0700 |
|---|---|---|
| committer | Gemini Lasswell | 2017-10-22 10:47:50 -0700 |
| commit | e07cf691decf01dc3cbe19a413708570b95bc41b (patch) | |
| tree | 0500a27e83dcef7fdf5bb846562e9d92c67fbf58 | |
| parent | 9c8f8de0f3e00d4f862fa5c17e3b46fcd23e5f7f (diff) | |
| download | emacs-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'.
| -rw-r--r-- | doc/lispref/edebug.texi | 23 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/emacs-lisp/edebug.el | 37 | ||||
| -rw-r--r-- | lisp/emacs-lisp/testcover.el | 23 |
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 | |||
| 1705 | call the new functions in place of its own for that definition. | 1705 | call 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 |
| 1709 | An abnormal hook run by Edebug after it wraps the body of a definition | 1709 | A function run by Edebug after it wraps the body of a definition |
| 1710 | or closure. After Edebug has initialized its own data, each function | 1710 | or closure. After Edebug has initialized its own data, this function |
| 1711 | is called with one argument, the symbol associated with the | 1711 | is called with one argument, the symbol associated with the |
| 1712 | definition, which may be the actual symbol defined or one generated by | 1712 | definition, which may be the actual symbol defined or one generated by |
| 1713 | Edebug. This hook may be used to set the @code{edebug-behavior} | 1713 | Edebug. This function may be used to set the @code{edebug-behavior} |
| 1714 | symbol property of each definition instrumented by Edebug. | 1714 | symbol property of each definition instrumented by Edebug. |
| 1715 | |||
| 1716 | By default @code{edebug-new-definition-functions} contains | ||
| 1717 | @code{edebug-announce-definition} which prints a message each time a | ||
| 1718 | definition is instrumented. If you are instrumenting a lot of code | ||
| 1719 | and 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 |
| 1724 | An abnormal hook run by Edebug after it instruments a form. | 1718 | To inspect or modify Edebug's instrumentation before it is used, set |
| 1725 | Each function is called with one argument, a form which has | 1719 | this variable to a function which takes one argument, an instrumented |
| 1726 | just been instrumented by Edebug. | 1720 | top-level form, and returns either the same or a replacement form, |
| 1721 | which Edebug will then use as the final result of instrumentation. | ||
| 1727 | @end defopt | 1722 | @end defopt |
| @@ -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 |
| 74 | using the new variable 'edebug-behavior-alist' and the new abnormal | 74 | using the new variables 'edebug-behavior-alist', |
| 75 | hooks '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 |
| 77 | globally or for individual definitions. | 77 | globally 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. |
| 1072 | Each function is called with one argument, a form which has just | 1072 | The function is called with one argument, a FORM which has just |
| 1073 | been instrumented for Edebugging.") | 1073 | been instrumented for Edebugging, and it should return either FORM |
| 1074 | 1074 | or 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 |
| 1077 | After Edebug has initialized its own data, each hook function is | 1077 | "Function to call after Edebug wraps a new definition. |
| 1078 | After Edebug has initialized its own data, this function is | ||
| 1078 | called with one argument, the symbol associated with the | 1079 | called with one argument, the symbol associated with the |
| 1079 | definition, which may be the actual symbol defined or one | 1080 | definition, which may be the actual symbol defined or one |
| 1080 | generated by Edebug.") | 1081 | generated by Edebug.") |
| @@ -1087,9 +1088,9 @@ Each definition instrumented by Edebug will have a | |||
| 1087 | the instrumented code is running, Edebug will look here for the | 1088 | the instrumented code is running, Edebug will look here for the |
| 1088 | implementations of `edebug-enter', `edebug-before', and | 1089 | implementations 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 |
| 1090 | purpose by adding an entry to this alist and a hook to | 1091 | purpose 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 |
| 1092 | for 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) |