diff options
| author | Stefan Monnier | 2019-05-01 12:45:37 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2019-05-01 12:45:37 -0400 |
| commit | 9e8e3975ad4ce02269168a30b75ce2b054b3387a (patch) | |
| tree | a2af79b2d18576c0c7fe7d635705efbe4fb915f2 | |
| parent | 5bd25c095eb7f7d148b47e6823c7eccd6416a693 (diff) | |
| download | emacs-9e8e3975ad4ce02269168a30b75ce2b054b3387a.tar.gz emacs-9e8e3975ad4ce02269168a30b75ce2b054b3387a.zip | |
* lisp/emacs-lisp/edebug.el: Better handle instrumentation of `end-of-defun`
Remove redundant :group args.
(edebug-read-top-level-form): Let-bind edebug-active.
(edebug-active): Move before this new first use.
| -rw-r--r-- | lisp/emacs-lisp/edebug.el | 85 |
1 files changed, 34 insertions, 51 deletions
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 6dfcc24493d..ab5553b4e83 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el | |||
| @@ -70,8 +70,7 @@ Each time it is set to a new value, Edebug will call those functions | |||
| 70 | once and then reset `edebug-setup-hook' to nil. You could use this | 70 | once and then reset `edebug-setup-hook' to nil. You could use this |
| 71 | to load up Edebug specifications associated with a package you are | 71 | to load up Edebug specifications associated with a package you are |
| 72 | using, but only when you also use Edebug." | 72 | using, but only when you also use Edebug." |
| 73 | :type 'hook | 73 | :type 'hook) |
| 74 | :group 'edebug) | ||
| 75 | 74 | ||
| 76 | ;; edebug-all-defs and edebug-all-forms need to be autoloaded | 75 | ;; edebug-all-defs and edebug-all-forms need to be autoloaded |
| 77 | ;; because the byte compiler binds them; as a result, if edebug | 76 | ;; because the byte compiler binds them; as a result, if edebug |
| @@ -88,8 +87,7 @@ You can use the command `edebug-all-defs' to toggle the value of this | |||
| 88 | variable. You may wish to make it local to each buffer with | 87 | variable. You may wish to make it local to each buffer with |
| 89 | \(make-local-variable \\='edebug-all-defs) in your | 88 | \(make-local-variable \\='edebug-all-defs) in your |
| 90 | `emacs-lisp-mode-hook'." | 89 | `emacs-lisp-mode-hook'." |
| 91 | :type 'boolean | 90 | :type 'boolean) |
| 92 | :group 'edebug) | ||
| 93 | 91 | ||
| 94 | ;; edebug-all-defs and edebug-all-forms need to be autoloaded | 92 | ;; edebug-all-defs and edebug-all-forms need to be autoloaded |
| 95 | ;; because the byte compiler binds them; as a result, if edebug | 93 | ;; because the byte compiler binds them; as a result, if edebug |
| @@ -100,8 +98,7 @@ variable. You may wish to make it local to each buffer with | |||
| 100 | "Non-nil means evaluation of all forms will instrument for Edebug. | 98 | "Non-nil means evaluation of all forms will instrument for Edebug. |
| 101 | This doesn't apply to loading or evaluations in the minibuffer. | 99 | This doesn't apply to loading or evaluations in the minibuffer. |
| 102 | Use the command `edebug-all-forms' to toggle the value of this option." | 100 | Use the command `edebug-all-forms' to toggle the value of this option." |
| 103 | :type 'boolean | 101 | :type 'boolean) |
| 104 | :group 'edebug) | ||
| 105 | 102 | ||
| 106 | (defcustom edebug-eval-macro-args nil | 103 | (defcustom edebug-eval-macro-args nil |
| 107 | "Non-nil means all macro call arguments may be evaluated. | 104 | "Non-nil means all macro call arguments may be evaluated. |
| @@ -110,8 +107,7 @@ macro call arguments as if they will be evaluated. | |||
| 110 | For each macro, an `edebug-form-spec' overrides this option. | 107 | For each macro, an `edebug-form-spec' overrides this option. |
| 111 | So to specify exceptions for macros that have some arguments evaluated | 108 | So to specify exceptions for macros that have some arguments evaluated |
| 112 | and some not, use `def-edebug-spec' to specify an `edebug-form-spec'." | 109 | and some not, use `def-edebug-spec' to specify an `edebug-form-spec'." |
| 113 | :type 'boolean | 110 | :type 'boolean) |
| 114 | :group 'edebug) | ||
| 115 | 111 | ||
| 116 | (defcustom edebug-max-depth 150 | 112 | (defcustom edebug-max-depth 150 |
| 117 | "Maximum recursion depth when instrumenting code. | 113 | "Maximum recursion depth when instrumenting code. |
| @@ -122,7 +118,6 @@ the error message \"Too deep - perhaps infinite loop in spec?\". | |||
| 122 | Make this limit larger to countermand that, but you may also need to | 118 | Make this limit larger to countermand that, but you may also need to |
| 123 | increase `max-lisp-eval-depth' and `max-specpdl-size'." | 119 | increase `max-lisp-eval-depth' and `max-specpdl-size'." |
| 124 | :type 'integer | 120 | :type 'integer |
| 125 | :group 'edebug | ||
| 126 | :version "26.1") | 121 | :version "26.1") |
| 127 | 122 | ||
| 128 | (defcustom edebug-save-windows t | 123 | (defcustom edebug-save-windows t |
| @@ -134,8 +129,7 @@ If the value is a list, only the listed windows are saved and | |||
| 134 | restored. | 129 | restored. |
| 135 | 130 | ||
| 136 | `edebug-toggle-save-windows' may be used to change this variable." | 131 | `edebug-toggle-save-windows' may be used to change this variable." |
| 137 | :type '(choice boolean (repeat string)) | 132 | :type '(choice boolean (repeat string))) |
| 138 | :group 'edebug) | ||
| 139 | 133 | ||
| 140 | (defcustom edebug-save-displayed-buffer-points nil | 134 | (defcustom edebug-save-displayed-buffer-points nil |
| 141 | "If non-nil, save and restore point in all displayed buffers. | 135 | "If non-nil, save and restore point in all displayed buffers. |
| @@ -148,8 +142,7 @@ window, the buffer's point will be changed to the window's point. | |||
| 148 | Saving and restoring point in all buffers is expensive, since it | 142 | Saving and restoring point in all buffers is expensive, since it |
| 149 | requires selecting each window twice, so enable this only if you | 143 | requires selecting each window twice, so enable this only if you |
| 150 | need it." | 144 | need it." |
| 151 | :type 'boolean | 145 | :type 'boolean) |
| 152 | :group 'edebug) | ||
| 153 | 146 | ||
| 154 | (defcustom edebug-initial-mode 'step | 147 | (defcustom edebug-initial-mode 'step |
| 155 | "Initial execution mode for Edebug, if non-nil. | 148 | "Initial execution mode for Edebug, if non-nil. |
| @@ -159,8 +152,7 @@ go, Go-nonstop, trace, Trace-fast, continue, and Continue-fast." | |||
| 159 | :type '(choice (const step) (const next) (const go) | 152 | :type '(choice (const step) (const next) (const go) |
| 160 | (const Go-nonstop) (const trace) | 153 | (const Go-nonstop) (const trace) |
| 161 | (const Trace-fast) (const continue) | 154 | (const Trace-fast) (const continue) |
| 162 | (const Continue-fast)) | 155 | (const Continue-fast))) |
| 163 | :group 'edebug) | ||
| 164 | 156 | ||
| 165 | (defcustom edebug-trace nil | 157 | (defcustom edebug-trace nil |
| 166 | "Non-nil means display a trace of function entry and exit. | 158 | "Non-nil means display a trace of function entry and exit. |
| @@ -169,8 +161,7 @@ function entry or exit per line, indented by the recursion level. | |||
| 169 | 161 | ||
| 170 | You can customize by replacing functions `edebug-print-trace-before' | 162 | You can customize by replacing functions `edebug-print-trace-before' |
| 171 | and `edebug-print-trace-after'." | 163 | and `edebug-print-trace-after'." |
| 172 | :type 'boolean | 164 | :type 'boolean) |
| 173 | :group 'edebug) | ||
| 174 | 165 | ||
| 175 | (defcustom edebug-test-coverage nil | 166 | (defcustom edebug-test-coverage nil |
| 176 | "If non-nil, Edebug tests coverage of all expressions debugged. | 167 | "If non-nil, Edebug tests coverage of all expressions debugged. |
| @@ -180,36 +171,30 @@ results are found. | |||
| 180 | 171 | ||
| 181 | Use `edebug-display-freq-count' to display the frequency count and | 172 | Use `edebug-display-freq-count' to display the frequency count and |
| 182 | coverage information for a definition." | 173 | coverage information for a definition." |
| 183 | :type 'boolean | 174 | :type 'boolean) |
| 184 | :group 'edebug) | ||
| 185 | 175 | ||
| 186 | (defcustom edebug-continue-kbd-macro nil | 176 | (defcustom edebug-continue-kbd-macro nil |
| 187 | "If non-nil, continue defining or executing any keyboard macro. | 177 | "If non-nil, continue defining or executing any keyboard macro. |
| 188 | Use this with caution since it is not debugged." | 178 | Use this with caution since it is not debugged." |
| 189 | :type 'boolean | 179 | :type 'boolean) |
| 190 | :group 'edebug) | ||
| 191 | 180 | ||
| 192 | 181 | ||
| 193 | (defcustom edebug-print-length 50 | 182 | (defcustom edebug-print-length 50 |
| 194 | "If non-nil, default value of `print-length' for printing results in Edebug." | 183 | "If non-nil, default value of `print-length' for printing results in Edebug." |
| 195 | :type '(choice integer (const nil)) | 184 | :type '(choice integer (const nil))) |
| 196 | :group 'edebug) | ||
| 197 | (defcustom edebug-print-level 50 | 185 | (defcustom edebug-print-level 50 |
| 198 | "If non-nil, default value of `print-level' for printing results in Edebug." | 186 | "If non-nil, default value of `print-level' for printing results in Edebug." |
| 199 | :type '(choice integer (const nil)) | 187 | :type '(choice integer (const nil))) |
| 200 | :group 'edebug) | ||
| 201 | (defcustom edebug-print-circle t | 188 | (defcustom edebug-print-circle t |
| 202 | "If non-nil, default value of `print-circle' for printing results in Edebug." | 189 | "If non-nil, default value of `print-circle' for printing results in Edebug." |
| 203 | :type 'boolean | 190 | :type 'boolean) |
| 204 | :group 'edebug) | ||
| 205 | 191 | ||
| 206 | (defcustom edebug-unwrap-results nil | 192 | (defcustom edebug-unwrap-results nil |
| 207 | "Non-nil if Edebug should unwrap results of expressions. | 193 | "Non-nil if Edebug should unwrap results of expressions. |
| 208 | That is, Edebug will try to remove its own instrumentation from the result. | 194 | That is, Edebug will try to remove its own instrumentation from the result. |
| 209 | This is useful when debugging macros where the results of expressions | 195 | This is useful when debugging macros where the results of expressions |
| 210 | are instrumented expressions." | 196 | are instrumented expressions." |
| 211 | :type 'boolean | 197 | :type 'boolean) |
| 212 | :group 'edebug) | ||
| 213 | 198 | ||
| 214 | (defcustom edebug-on-error t | 199 | (defcustom edebug-on-error t |
| 215 | "Value bound to `debug-on-error' while Edebug is active. | 200 | "Value bound to `debug-on-error' while Edebug is active. |
| @@ -225,30 +210,25 @@ After execution is resumed, the error is signaled again." | |||
| 225 | (repeat :menu-tag "When" | 210 | (repeat :menu-tag "When" |
| 226 | :value (nil) | 211 | :value (nil) |
| 227 | (symbol :format "%v")) | 212 | (symbol :format "%v")) |
| 228 | (const :tag "always" t)) | 213 | (const :tag "always" t))) |
| 229 | :group 'edebug) | ||
| 230 | 214 | ||
| 231 | (defcustom edebug-on-quit t | 215 | (defcustom edebug-on-quit t |
| 232 | "Value bound to `debug-on-quit' while Edebug is active." | 216 | "Value bound to `debug-on-quit' while Edebug is active." |
| 233 | :type 'boolean | 217 | :type 'boolean) |
| 234 | :group 'edebug) | ||
| 235 | 218 | ||
| 236 | (defcustom edebug-global-break-condition nil | 219 | (defcustom edebug-global-break-condition nil |
| 237 | "If non-nil, an expression to test for at every stop point. | 220 | "If non-nil, an expression to test for at every stop point. |
| 238 | If the result is non-nil, then break. Errors are ignored." | 221 | If the result is non-nil, then break. Errors are ignored." |
| 239 | :type 'sexp | 222 | :type 'sexp |
| 240 | :risky t | 223 | :risky t) |
| 241 | :group 'edebug) | ||
| 242 | 224 | ||
| 243 | (defcustom edebug-sit-for-seconds 1 | 225 | (defcustom edebug-sit-for-seconds 1 |
| 244 | "Number of seconds to pause when execution mode is `trace' or `continue'." | 226 | "Number of seconds to pause when execution mode is `trace' or `continue'." |
| 245 | :type 'number | 227 | :type 'number) |
| 246 | :group 'edebug) | ||
| 247 | 228 | ||
| 248 | (defcustom edebug-sit-on-break t | 229 | (defcustom edebug-sit-on-break t |
| 249 | "Whether or not to pause for `edebug-sit-for-seconds' on reaching a break." | 230 | "Whether or not to pause for `edebug-sit-for-seconds' on reaching a break." |
| 250 | :type 'boolean | 231 | :type 'boolean |
| 251 | :group 'edebug | ||
| 252 | :version "26.1") | 232 | :version "26.1") |
| 253 | 233 | ||
| 254 | ;;; Form spec utilities. | 234 | ;;; Form spec utilities. |
| @@ -547,8 +527,13 @@ already is one.)" | |||
| 547 | (edebug-read-top-level-form))))) | 527 | (edebug-read-top-level-form))))) |
| 548 | 528 | ||
| 549 | 529 | ||
| 530 | (defvar edebug-active nil) ;; Non-nil when edebug is active | ||
| 531 | |||
| 550 | (defun edebug-read-top-level-form () | 532 | (defun edebug-read-top-level-form () |
| 551 | (let ((starting-point (point))) | 533 | (let ((starting-point (point)) |
| 534 | ;; Don't enter Edebug while doing that, in case we're trying to | ||
| 535 | ;; instrument things like end-of-defun. | ||
| 536 | (edebug-active t)) | ||
| 552 | (end-of-defun) | 537 | (end-of-defun) |
| 553 | (beginning-of-defun) | 538 | (beginning-of-defun) |
| 554 | (prog1 | 539 | (prog1 |
| @@ -586,7 +571,7 @@ already is one.)" | |||
| 586 | (defun edebug-uninstall-read-eval-functions () | 571 | (defun edebug-uninstall-read-eval-functions () |
| 587 | (interactive) | 572 | (interactive) |
| 588 | (remove-function load-read-function #'edebug--read) | 573 | (remove-function load-read-function #'edebug--read) |
| 589 | (advice-remove 'eval-defun 'edebug-eval-defun)) | 574 | (advice-remove 'eval-defun #'edebug-eval-defun)) |
| 590 | 575 | ||
| 591 | ;;; Edebug internal data | 576 | ;;; Edebug internal data |
| 592 | 577 | ||
| @@ -2225,8 +2210,6 @@ into `edebug--cl-macrolet-defs' which is checked in `edebug-list-form-args'." | |||
| 2225 | 2210 | ||
| 2226 | ;;; The debugger itself | 2211 | ;;; The debugger itself |
| 2227 | 2212 | ||
| 2228 | (defvar edebug-active nil) ;; Non-nil when edebug is active | ||
| 2229 | |||
| 2230 | (defvar edebug-stack nil) | 2213 | (defvar edebug-stack nil) |
| 2231 | ;; Stack of active functions evaluated via edebug. | 2214 | ;; Stack of active functions evaluated via edebug. |
| 2232 | ;; Should be nil at the top level. | 2215 | ;; Should be nil at the top level. |
| @@ -2304,8 +2287,8 @@ and run its entry function, and set up `edebug-before' and | |||
| 2304 | `edebug-after'." | 2287 | `edebug-after'." |
| 2305 | (cl-letf* ((behavior (get func 'edebug-behavior)) | 2288 | (cl-letf* ((behavior (get func 'edebug-behavior)) |
| 2306 | (functions (cdr (assoc behavior edebug-behavior-alist))) | 2289 | (functions (cdr (assoc behavior edebug-behavior-alist))) |
| 2307 | ((symbol-function #'edebug-before) (nth 1 functions)) | 2290 | ((symbol-function 'edebug-before) (nth 1 functions)) |
| 2308 | ((symbol-function #'edebug-after) (nth 2 functions))) | 2291 | ((symbol-function 'edebug-after) (nth 2 functions))) |
| 2309 | (funcall (nth 0 functions) func args body))) | 2292 | (funcall (nth 0 functions) func args body))) |
| 2310 | 2293 | ||
| 2311 | (defun edebug-default-enter (function args body) | 2294 | (defun edebug-default-enter (function args body) |
| @@ -2335,7 +2318,7 @@ and run its entry function, and set up `edebug-before' and | |||
| 2335 | (debug-on-error (or debug-on-error edebug-on-error)) | 2318 | (debug-on-error (or debug-on-error edebug-on-error)) |
| 2336 | (debug-on-quit edebug-on-quit)) | 2319 | (debug-on-quit edebug-on-quit)) |
| 2337 | (unwind-protect | 2320 | (unwind-protect |
| 2338 | (let ((signal-hook-function 'edebug-signal)) | 2321 | (let ((signal-hook-function #'edebug-signal)) |
| 2339 | (setq edebug-execution-mode (or edebug-next-execution-mode | 2322 | (setq edebug-execution-mode (or edebug-next-execution-mode |
| 2340 | edebug-initial-mode | 2323 | edebug-initial-mode |
| 2341 | edebug-execution-mode) | 2324 | edebug-execution-mode) |
| @@ -2905,7 +2888,7 @@ See `edebug-behavior-alist' for implementations.") | |||
| 2905 | (recursive-edit) ; <<<<<<<<<< Recursive edit | 2888 | (recursive-edit) ; <<<<<<<<<< Recursive edit |
| 2906 | 2889 | ||
| 2907 | ;; Do the following, even if quit occurs. | 2890 | ;; Do the following, even if quit occurs. |
| 2908 | (setq signal-hook-function 'edebug-signal) | 2891 | (setq signal-hook-function #'edebug-signal) |
| 2909 | (if edebug-backtrace-buffer | 2892 | (if edebug-backtrace-buffer |
| 2910 | (kill-buffer edebug-backtrace-buffer)) | 2893 | (kill-buffer edebug-backtrace-buffer)) |
| 2911 | 2894 | ||
| @@ -3810,7 +3793,7 @@ Options: | |||
| 3810 | (if (consp setting) | 3793 | (if (consp setting) |
| 3811 | (set (car setting) (cdr setting)) | 3794 | (set (car setting) (cdr setting)) |
| 3812 | (kill-local-variable setting)))) | 3795 | (kill-local-variable setting)))) |
| 3813 | (remove-hook 'kill-buffer-hook 'edebug-kill-buffer t)) | 3796 | (remove-hook 'kill-buffer-hook #'edebug-kill-buffer t)) |
| 3814 | (pcase-dolist (`(,var . ,val) '((buffer-read-only . t))) | 3797 | (pcase-dolist (`(,var . ,val) '((buffer-read-only . t))) |
| 3815 | (push | 3798 | (push |
| 3816 | (if (local-variable-p var) (cons var (symbol-value var)) var) | 3799 | (if (local-variable-p var) (cons var (symbol-value var)) var) |
| @@ -3818,7 +3801,7 @@ Options: | |||
| 3818 | (set (make-local-variable var) val)) | 3801 | (set (make-local-variable var) val)) |
| 3819 | ;; Append `edebug-kill-buffer' to the hook to avoid interfering with | 3802 | ;; Append `edebug-kill-buffer' to the hook to avoid interfering with |
| 3820 | ;; other entries that are unguarded against deleted buffer. | 3803 | ;; other entries that are unguarded against deleted buffer. |
| 3821 | (add-hook 'kill-buffer-hook 'edebug-kill-buffer t t))) | 3804 | (add-hook 'kill-buffer-hook #'edebug-kill-buffer t t))) |
| 3822 | 3805 | ||
| 3823 | (defun edebug-kill-buffer () | 3806 | (defun edebug-kill-buffer () |
| 3824 | "Used on `kill-buffer-hook' when Edebug is operating in a buffer of Lisp code." | 3807 | "Used on `kill-buffer-hook' when Edebug is operating in a buffer of Lisp code." |
| @@ -4016,7 +3999,7 @@ This should be a list of `edebug---frame' objects.") | |||
| 4016 | (pop-to-buffer edebug-backtrace-buffer) | 3999 | (pop-to-buffer edebug-backtrace-buffer) |
| 4017 | (unless (derived-mode-p 'backtrace-mode) | 4000 | (unless (derived-mode-p 'backtrace-mode) |
| 4018 | (backtrace-mode) | 4001 | (backtrace-mode) |
| 4019 | (add-hook 'backtrace-goto-source-functions 'edebug--backtrace-goto-source)) | 4002 | (add-hook 'backtrace-goto-source-functions #'edebug--backtrace-goto-source)) |
| 4020 | (setq edebug-instrumented-backtrace-frames | 4003 | (setq edebug-instrumented-backtrace-frames |
| 4021 | (backtrace-get-frames 'edebug-debugger | 4004 | (backtrace-get-frames 'edebug-debugger |
| 4022 | :constructor #'edebug--make-frame) | 4005 | :constructor #'edebug--make-frame) |
| @@ -4396,8 +4379,8 @@ With prefix argument, make it a temporary breakpoint." | |||
| 4396 | ;; We still want to run unload-feature to completion | 4379 | ;; We still want to run unload-feature to completion |
| 4397 | (run-with-idle-timer 0 nil #'(lambda () (unload-feature 'edebug))))) | 4380 | (run-with-idle-timer 0 nil #'(lambda () (unload-feature 'edebug))))) |
| 4398 | (remove-hook 'called-interactively-p-functions | 4381 | (remove-hook 'called-interactively-p-functions |
| 4399 | 'edebug--called-interactively-skip) | 4382 | #'edebug--called-interactively-skip) |
| 4400 | (remove-hook 'cl-read-load-hooks 'edebug--require-cl-read) | 4383 | (remove-hook 'cl-read-load-hooks #'edebug--require-cl-read) |
| 4401 | (edebug-uninstall-read-eval-functions) | 4384 | (edebug-uninstall-read-eval-functions) |
| 4402 | ;; Continue standard unloading. | 4385 | ;; Continue standard unloading. |
| 4403 | nil) | 4386 | nil) |