Skip to content

Commit 9e8e397

Browse files
committed
* 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.
1 parent 5bd25c0 commit 9e8e397

File tree

1 file changed

+34
-51
lines changed

1 file changed

+34
-51
lines changed

lisp/emacs-lisp/edebug.el

Lines changed: 34 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ Each time it is set to a new value, Edebug will call those functions
7070
once and then reset `edebug-setup-hook' to nil. You could use this
7171
to load up Edebug specifications associated with a package you are
7272
using, but only when you also use Edebug."
73-
:type 'hook
74-
:group 'edebug)
73+
:type 'hook)
7574

7675
;; edebug-all-defs and edebug-all-forms need to be autoloaded
7776
;; 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
8887
variable. You may wish to make it local to each buffer with
8988
\(make-local-variable \\='edebug-all-defs) in your
9089
`emacs-lisp-mode-hook'."
91-
:type 'boolean
92-
:group 'edebug)
90+
:type 'boolean)
9391

9492
;; edebug-all-defs and edebug-all-forms need to be autoloaded
9593
;; 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
10098
"Non-nil means evaluation of all forms will instrument for Edebug.
10199
This doesn't apply to loading or evaluations in the minibuffer.
102100
Use the command `edebug-all-forms' to toggle the value of this option."
103-
:type 'boolean
104-
:group 'edebug)
101+
:type 'boolean)
105102

106103
(defcustom edebug-eval-macro-args nil
107104
"Non-nil means all macro call arguments may be evaluated.
@@ -110,8 +107,7 @@ macro call arguments as if they will be evaluated.
110107
For each macro, an `edebug-form-spec' overrides this option.
111108
So to specify exceptions for macros that have some arguments evaluated
112109
and some not, use `def-edebug-spec' to specify an `edebug-form-spec'."
113-
:type 'boolean
114-
:group 'edebug)
110+
:type 'boolean)
115111

116112
(defcustom edebug-max-depth 150
117113
"Maximum recursion depth when instrumenting code.
@@ -122,7 +118,6 @@ the error message \"Too deep - perhaps infinite loop in spec?\".
122118
Make this limit larger to countermand that, but you may also need to
123119
increase `max-lisp-eval-depth' and `max-specpdl-size'."
124120
:type 'integer
125-
:group 'edebug
126121
:version "26.1")
127122

128123
(defcustom edebug-save-windows t
@@ -134,8 +129,7 @@ If the value is a list, only the listed windows are saved and
134129
restored.
135130
136131
`edebug-toggle-save-windows' may be used to change this variable."
137-
:type '(choice boolean (repeat string))
138-
:group 'edebug)
132+
:type '(choice boolean (repeat string)))
139133

140134
(defcustom edebug-save-displayed-buffer-points nil
141135
"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.
148142
Saving and restoring point in all buffers is expensive, since it
149143
requires selecting each window twice, so enable this only if you
150144
need it."
151-
:type 'boolean
152-
:group 'edebug)
145+
:type 'boolean)
153146

154147
(defcustom edebug-initial-mode 'step
155148
"Initial execution mode for Edebug, if non-nil.
@@ -159,8 +152,7 @@ go, Go-nonstop, trace, Trace-fast, continue, and Continue-fast."
159152
:type '(choice (const step) (const next) (const go)
160153
(const Go-nonstop) (const trace)
161154
(const Trace-fast) (const continue)
162-
(const Continue-fast))
163-
:group 'edebug)
155+
(const Continue-fast)))
164156

165157
(defcustom edebug-trace nil
166158
"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.
169161
170162
You can customize by replacing functions `edebug-print-trace-before'
171163
and `edebug-print-trace-after'."
172-
:type 'boolean
173-
:group 'edebug)
164+
:type 'boolean)
174165

175166
(defcustom edebug-test-coverage nil
176167
"If non-nil, Edebug tests coverage of all expressions debugged.
@@ -180,36 +171,30 @@ results are found.
180171
181172
Use `edebug-display-freq-count' to display the frequency count and
182173
coverage information for a definition."
183-
:type 'boolean
184-
:group 'edebug)
174+
:type 'boolean)
185175

186176
(defcustom edebug-continue-kbd-macro nil
187177
"If non-nil, continue defining or executing any keyboard macro.
188178
Use this with caution since it is not debugged."
189-
:type 'boolean
190-
:group 'edebug)
179+
:type 'boolean)
191180

192181

193182
(defcustom edebug-print-length 50
194183
"If non-nil, default value of `print-length' for printing results in Edebug."
195-
:type '(choice integer (const nil))
196-
:group 'edebug)
184+
:type '(choice integer (const nil)))
197185
(defcustom edebug-print-level 50
198186
"If non-nil, default value of `print-level' for printing results in Edebug."
199-
:type '(choice integer (const nil))
200-
:group 'edebug)
187+
:type '(choice integer (const nil)))
201188
(defcustom edebug-print-circle t
202189
"If non-nil, default value of `print-circle' for printing results in Edebug."
203-
:type 'boolean
204-
:group 'edebug)
190+
:type 'boolean)
205191

206192
(defcustom edebug-unwrap-results nil
207193
"Non-nil if Edebug should unwrap results of expressions.
208194
That is, Edebug will try to remove its own instrumentation from the result.
209195
This is useful when debugging macros where the results of expressions
210196
are instrumented expressions."
211-
:type 'boolean
212-
:group 'edebug)
197+
:type 'boolean)
213198

214199
(defcustom edebug-on-error t
215200
"Value bound to `debug-on-error' while Edebug is active.
@@ -225,30 +210,25 @@ After execution is resumed, the error is signaled again."
225210
(repeat :menu-tag "When"
226211
:value (nil)
227212
(symbol :format "%v"))
228-
(const :tag "always" t))
229-
:group 'edebug)
213+
(const :tag "always" t)))
230214

231215
(defcustom edebug-on-quit t
232216
"Value bound to `debug-on-quit' while Edebug is active."
233-
:type 'boolean
234-
:group 'edebug)
217+
:type 'boolean)
235218

236219
(defcustom edebug-global-break-condition nil
237220
"If non-nil, an expression to test for at every stop point.
238221
If the result is non-nil, then break. Errors are ignored."
239222
:type 'sexp
240-
:risky t
241-
:group 'edebug)
223+
:risky t)
242224

243225
(defcustom edebug-sit-for-seconds 1
244226
"Number of seconds to pause when execution mode is `trace' or `continue'."
245-
:type 'number
246-
:group 'edebug)
227+
:type 'number)
247228

248229
(defcustom edebug-sit-on-break t
249230
"Whether or not to pause for `edebug-sit-for-seconds' on reaching a break."
250231
:type 'boolean
251-
:group 'edebug
252232
:version "26.1")
253233

254234
;;; Form spec utilities.
@@ -547,8 +527,13 @@ already is one.)"
547527
(edebug-read-top-level-form)))))
548528

549529

530+
(defvar edebug-active nil) ;; Non-nil when edebug is active
531+
550532
(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))
552537
(end-of-defun)
553538
(beginning-of-defun)
554539
(prog1
@@ -586,7 +571,7 @@ already is one.)"
586571
(defun edebug-uninstall-read-eval-functions ()
587572
(interactive)
588573
(remove-function load-read-function #'edebug--read)
589-
(advice-remove 'eval-defun 'edebug-eval-defun))
574+
(advice-remove 'eval-defun #'edebug-eval-defun))
590575

591576
;;; Edebug internal data
592577

@@ -2225,8 +2210,6 @@ into `edebug--cl-macrolet-defs' which is checked in `edebug-list-form-args'."
22252210

22262211
;;; The debugger itself
22272212

2228-
(defvar edebug-active nil) ;; Non-nil when edebug is active
2229-
22302213
(defvar edebug-stack nil)
22312214
;; Stack of active functions evaluated via edebug.
22322215
;; Should be nil at the top level.
@@ -2304,8 +2287,8 @@ and run its entry function, and set up `edebug-before' and
23042287
`edebug-after'."
23052288
(cl-letf* ((behavior (get func 'edebug-behavior))
23062289
(functions (cdr (assoc behavior edebug-behavior-alist)))
2307-
((symbol-function #'edebug-before) (nth 1 functions))
2308-
((symbol-function #'edebug-after) (nth 2 functions)))
2290+
((symbol-function 'edebug-before) (nth 1 functions))
2291+
((symbol-function 'edebug-after) (nth 2 functions)))
23092292
(funcall (nth 0 functions) func args body)))
23102293

23112294
(defun edebug-default-enter (function args body)
@@ -2335,7 +2318,7 @@ and run its entry function, and set up `edebug-before' and
23352318
(debug-on-error (or debug-on-error edebug-on-error))
23362319
(debug-on-quit edebug-on-quit))
23372320
(unwind-protect
2338-
(let ((signal-hook-function 'edebug-signal))
2321+
(let ((signal-hook-function #'edebug-signal))
23392322
(setq edebug-execution-mode (or edebug-next-execution-mode
23402323
edebug-initial-mode
23412324
edebug-execution-mode)
@@ -2905,7 +2888,7 @@ See `edebug-behavior-alist' for implementations.")
29052888
(recursive-edit) ; <<<<<<<<<< Recursive edit
29062889

29072890
;; Do the following, even if quit occurs.
2908-
(setq signal-hook-function 'edebug-signal)
2891+
(setq signal-hook-function #'edebug-signal)
29092892
(if edebug-backtrace-buffer
29102893
(kill-buffer edebug-backtrace-buffer))
29112894

@@ -3810,15 +3793,15 @@ Options:
38103793
(if (consp setting)
38113794
(set (car setting) (cdr setting))
38123795
(kill-local-variable setting))))
3813-
(remove-hook 'kill-buffer-hook 'edebug-kill-buffer t))
3796+
(remove-hook 'kill-buffer-hook #'edebug-kill-buffer t))
38143797
(pcase-dolist (`(,var . ,val) '((buffer-read-only . t)))
38153798
(push
38163799
(if (local-variable-p var) (cons var (symbol-value var)) var)
38173800
edebug--mode-saved-vars)
38183801
(set (make-local-variable var) val))
38193802
;; Append `edebug-kill-buffer' to the hook to avoid interfering with
38203803
;; 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)))
38223805

38233806
(defun edebug-kill-buffer ()
38243807
"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.")
40163999
(pop-to-buffer edebug-backtrace-buffer)
40174000
(unless (derived-mode-p 'backtrace-mode)
40184001
(backtrace-mode)
4019-
(add-hook 'backtrace-goto-source-functions 'edebug--backtrace-goto-source))
4002+
(add-hook 'backtrace-goto-source-functions #'edebug--backtrace-goto-source))
40204003
(setq edebug-instrumented-backtrace-frames
40214004
(backtrace-get-frames 'edebug-debugger
40224005
:constructor #'edebug--make-frame)
@@ -4396,8 +4379,8 @@ With prefix argument, make it a temporary breakpoint."
43964379
;; We still want to run unload-feature to completion
43974380
(run-with-idle-timer 0 nil #'(lambda () (unload-feature 'edebug)))))
43984381
(remove-hook 'called-interactively-p-functions
4399-
'edebug--called-interactively-skip)
4400-
(remove-hook 'cl-read-load-hooks 'edebug--require-cl-read)
4382+
#'edebug--called-interactively-skip)
4383+
(remove-hook 'cl-read-load-hooks #'edebug--require-cl-read)
44014384
(edebug-uninstall-read-eval-functions)
44024385
;; Continue standard unloading.
44034386
nil)

0 commit comments

Comments
 (0)