diff options
| author | Lars Ingebrigtsen | 2019-10-20 23:16:04 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-10-20 23:46:50 +0200 |
| commit | 78cb3791fa11c95756ee3917c63cfea774f128a2 (patch) | |
| tree | 033aa6db106544a772e158046bd95adf34594180 | |
| parent | b6bf5327908d310fabf7012af6790c7abc2114f4 (diff) | |
| download | emacs-78cb3791fa11c95756ee3917c63cfea774f128a2.tar.gz emacs-78cb3791fa11c95756ee3917c63cfea774f128a2.zip | |
Add a command to toggle an edebug breakpoint
* doc/lispref/edebug.texi (Breakpoints): Document this.
* lisp/emacs-lisp/edebug.el (edebug-disabled-breakpoint): New face
(bug#23472).
(edebug-enabled-breakpoint): Rename.
(edebug--overlay-breakpoints): Use the new face.
(edebug-toggle-disable-breakpoint): New command and keystroke.
| -rw-r--r-- | doc/lispref/edebug.texi | 10 | ||||
| -rw-r--r-- | etc/NEWS | 14 | ||||
| -rw-r--r-- | lisp/emacs-lisp/edebug.el | 43 |
3 files changed, 58 insertions, 9 deletions
diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi index 03efa985ba9..43665ea9ecd 100644 --- a/doc/lispref/edebug.texi +++ b/doc/lispref/edebug.texi | |||
| @@ -497,8 +497,8 @@ Edebug commands for breakpoints: | |||
| 497 | Set a breakpoint at the stop point at or after point | 497 | Set a breakpoint at the stop point at or after point |
| 498 | (@code{edebug-set-breakpoint}). If you use a prefix argument, the | 498 | (@code{edebug-set-breakpoint}). If you use a prefix argument, the |
| 499 | breakpoint is temporary---it turns off the first time it stops the | 499 | breakpoint is temporary---it turns off the first time it stops the |
| 500 | program. An overlay with the @code{edebug-breakpoint} face is put at | 500 | program. An overlay with the @code{edebug-enabled-breakpoint} or |
| 501 | the breakpoint. | 501 | @code{edebug-disabled-breakpoint} faces is put at the breakpoint. |
| 502 | 502 | ||
| 503 | @item u | 503 | @item u |
| 504 | Unset the breakpoint (if any) at the stop point at or after | 504 | Unset the breakpoint (if any) at the stop point at or after |
| @@ -508,6 +508,12 @@ point (@code{edebug-unset-breakpoint}). | |||
| 508 | Unset any breakpoints in the current form | 508 | Unset any breakpoints in the current form |
| 509 | (@code{edebug-unset-breakpoints}). | 509 | (@code{edebug-unset-breakpoints}). |
| 510 | 510 | ||
| 511 | @item D | ||
| 512 | Toggle whether to disable the breakpoint near point | ||
| 513 | (@code{edebug-toggle-disable-breakpoint}). This command is mostly | ||
| 514 | useful if the breakpoint is conditional and it would take some work to | ||
| 515 | recreate the condition. | ||
| 516 | |||
| 511 | @item x @var{condition} @key{RET} | 517 | @item x @var{condition} @key{RET} |
| 512 | Set a conditional breakpoint which stops the program only if | 518 | Set a conditional breakpoint which stops the program only if |
| 513 | evaluating @var{condition} produces a non-@code{nil} value | 519 | evaluating @var{condition} produces a non-@code{nil} value |
| @@ -1462,9 +1462,17 @@ the Elisp manual for documentation of the new mode and its commands. | |||
| 1462 | 1462 | ||
| 1463 | ** Edebug | 1463 | ** Edebug |
| 1464 | 1464 | ||
| 1465 | *** New face 'edebug-breakpoint' | 1465 | +++ |
| 1466 | When setting breakpoints in Edebug, an overlay with this face is | 1466 | *** New faces 'edebug-enabled-breakpoint' and 'edebug-disabled-breakpoint' |
| 1467 | placed over the point in question. | 1467 | When setting breakpoints in Edebug, an overlay with these faces are |
| 1468 | placed over the point in question, depending on whether they are | ||
| 1469 | enabled or not. | ||
| 1470 | |||
| 1471 | +++ | ||
| 1472 | *** New command 'edebug-toggle-disable-breakpoint' | ||
| 1473 | This command allows you to disable a breakpoint temporarily. This is | ||
| 1474 | mainly useful with breakpoints that are conditional and would take | ||
| 1475 | some time to recreate. | ||
| 1468 | 1476 | ||
| 1469 | +++ | 1477 | +++ |
| 1470 | *** New command 'edebug-unset-breakpoints' | 1478 | *** New command 'edebug-unset-breakpoints' |
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index d01654927e7..a646ce6febe 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el | |||
| @@ -63,8 +63,16 @@ | |||
| 63 | "A source-level debugger for Emacs Lisp." | 63 | "A source-level debugger for Emacs Lisp." |
| 64 | :group 'lisp) | 64 | :group 'lisp) |
| 65 | 65 | ||
| 66 | (defface edebug-breakpoint '((t :inherit highlight)) | 66 | (defface edebug-enabled-breakpoint '((t :inherit highlight)) |
| 67 | "Face used to mark breakpoints." | 67 | "Face used to mark enabled breakpoints." |
| 68 | :version "27.1") | ||
| 69 | |||
| 70 | (defface edebug-disabled-breakpoint | ||
| 71 | '((((class color) (min-colors 88) (background light)) | ||
| 72 | :background "#ddffdd" :extend t) | ||
| 73 | (((class color) (min-colors 88) (background dark)) | ||
| 74 | :background "#335533" :extend t)) | ||
| 75 | "Face used to mark disabled breakpoints." | ||
| 68 | :version "27.1") | 76 | :version "27.1") |
| 69 | 77 | ||
| 70 | (defcustom edebug-setup-hook nil | 78 | (defcustom edebug-setup-hook nil |
| @@ -2536,6 +2544,7 @@ See `edebug-behavior-alist' for implementations.") | |||
| 2536 | (edebug-breakpoints (car (cdr edebug-data))) ; list of breakpoints | 2544 | (edebug-breakpoints (car (cdr edebug-data))) ; list of breakpoints |
| 2537 | (edebug-break-data (assq offset-index edebug-breakpoints)) | 2545 | (edebug-break-data (assq offset-index edebug-breakpoints)) |
| 2538 | (edebug-break-condition (car (cdr edebug-break-data))) | 2546 | (edebug-break-condition (car (cdr edebug-break-data))) |
| 2547 | (breakpoint-disabled (nth 4 edebug-break-data)) | ||
| 2539 | (edebug-global-break | 2548 | (edebug-global-break |
| 2540 | (if edebug-global-break-condition | 2549 | (if edebug-global-break-condition |
| 2541 | (condition-case nil | 2550 | (condition-case nil |
| @@ -2549,6 +2558,7 @@ See `edebug-behavior-alist' for implementations.") | |||
| 2549 | (setq edebug-break | 2558 | (setq edebug-break |
| 2550 | (or edebug-global-break | 2559 | (or edebug-global-break |
| 2551 | (and edebug-break-data | 2560 | (and edebug-break-data |
| 2561 | (not breakpoint-disabled) | ||
| 2552 | (or (not edebug-break-condition) | 2562 | (or (not edebug-break-condition) |
| 2553 | (setq edebug-break-result | 2563 | (setq edebug-break-result |
| 2554 | (edebug-eval edebug-break-condition)))))) | 2564 | (edebug-eval edebug-break-condition)))))) |
| @@ -3206,7 +3216,8 @@ the breakpoint." | |||
| 3206 | (edebug-sort-alist | 3216 | (edebug-sort-alist |
| 3207 | (cons | 3217 | (cons |
| 3208 | (list index condition temporary | 3218 | (list index condition temporary |
| 3209 | (set-marker (make-marker) position)) | 3219 | (set-marker (make-marker) position) |
| 3220 | nil) | ||
| 3210 | edebug-breakpoints) | 3221 | edebug-breakpoints) |
| 3211 | '<)) | 3222 | '<)) |
| 3212 | (if condition | 3223 | (if condition |
| @@ -3236,7 +3247,10 @@ the breakpoint." | |||
| 3236 | (let* ((pos (+ start (aref offsets (car breakpoint)))) | 3247 | (let* ((pos (+ start (aref offsets (car breakpoint)))) |
| 3237 | (overlay (make-overlay pos (1+ pos)))) | 3248 | (overlay (make-overlay pos (1+ pos)))) |
| 3238 | (overlay-put overlay 'edebug t) | 3249 | (overlay-put overlay 'edebug t) |
| 3239 | (overlay-put overlay 'face 'edebug-breakpoint)))))) | 3250 | (overlay-put overlay 'face |
| 3251 | (if (nth 4 breakpoint) | ||
| 3252 | 'edebug-disabled-breakpoint | ||
| 3253 | 'edebug-enabled-breakpoint))))))) | ||
| 3240 | 3254 | ||
| 3241 | (defun edebug--overlay-breakpoints-remove (start end) | 3255 | (defun edebug--overlay-breakpoints-remove (start end) |
| 3242 | (dolist (overlay (overlays-in start end)) | 3256 | (dolist (overlay (overlays-in start end)) |
| @@ -3271,6 +3285,22 @@ With prefix argument, make it a temporary breakpoint." | |||
| 3271 | (goto-char (nth 3 breakpoint)) | 3285 | (goto-char (nth 3 breakpoint)) |
| 3272 | (edebug-modify-breakpoint nil))))) | 3286 | (edebug-modify-breakpoint nil))))) |
| 3273 | 3287 | ||
| 3288 | (defun edebug-toggle-disable-breakpoint () | ||
| 3289 | "Toggle whether the breakpoint near point is disabled." | ||
| 3290 | (interactive) | ||
| 3291 | (let ((stop-point (edebug-find-stop-point))) | ||
| 3292 | (unless stop-point | ||
| 3293 | (user-error "No stop point near point")) | ||
| 3294 | (let* ((name (car stop-point)) | ||
| 3295 | (index (cdr stop-point)) | ||
| 3296 | (data (get name 'edebug)) | ||
| 3297 | (breakpoint (assq index (nth 1 data)))) | ||
| 3298 | (unless breakpoint | ||
| 3299 | (user-error "No breakpoint near point")) | ||
| 3300 | (setf (nth 4 breakpoint) | ||
| 3301 | (not (nth 4 breakpoint))) | ||
| 3302 | (edebug--overlay-breakpoints name)))) | ||
| 3303 | |||
| 3274 | (defun edebug-set-global-break-condition (expression) | 3304 | (defun edebug-set-global-break-condition (expression) |
| 3275 | "Set `edebug-global-break-condition' to EXPRESSION." | 3305 | "Set `edebug-global-break-condition' to EXPRESSION." |
| 3276 | (interactive | 3306 | (interactive |
| @@ -3779,6 +3809,7 @@ be installed in `emacs-lisp-mode-map'.") | |||
| 3779 | (define-key map "B" 'edebug-next-breakpoint) | 3809 | (define-key map "B" 'edebug-next-breakpoint) |
| 3780 | (define-key map "x" 'edebug-set-conditional-breakpoint) | 3810 | (define-key map "x" 'edebug-set-conditional-breakpoint) |
| 3781 | (define-key map "X" 'edebug-set-global-break-condition) | 3811 | (define-key map "X" 'edebug-set-global-break-condition) |
| 3812 | (define-key map "D" 'edebug-toggle-disable-breakpoint) | ||
| 3782 | 3813 | ||
| 3783 | ;; evaluation | 3814 | ;; evaluation |
| 3784 | (define-key map "r" 'edebug-previous-result) | 3815 | (define-key map "r" 'edebug-previous-result) |
| @@ -3834,8 +3865,10 @@ be installed in `emacs-lisp-mode-map'.") | |||
| 3834 | ;; breakpoints | 3865 | ;; breakpoints |
| 3835 | (define-key map "b" 'edebug-set-breakpoint) | 3866 | (define-key map "b" 'edebug-set-breakpoint) |
| 3836 | (define-key map "u" 'edebug-unset-breakpoint) | 3867 | (define-key map "u" 'edebug-unset-breakpoint) |
| 3868 | (define-key map "U" 'edebug-unset-breakpoints) | ||
| 3837 | (define-key map "x" 'edebug-set-conditional-breakpoint) | 3869 | (define-key map "x" 'edebug-set-conditional-breakpoint) |
| 3838 | (define-key map "X" 'edebug-set-global-break-condition) | 3870 | (define-key map "X" 'edebug-set-global-break-condition) |
| 3871 | (define-key map "D" 'edebug-toggle-disable-breakpoint) | ||
| 3839 | 3872 | ||
| 3840 | ;; views | 3873 | ;; views |
| 3841 | (define-key map "w" 'edebug-where) | 3874 | (define-key map "w" 'edebug-where) |
| @@ -4381,6 +4414,8 @@ It is removed when you hit any char." | |||
| 4381 | ("Breaks" | 4414 | ("Breaks" |
| 4382 | ["Set Breakpoint" edebug-set-breakpoint t] | 4415 | ["Set Breakpoint" edebug-set-breakpoint t] |
| 4383 | ["Unset Breakpoint" edebug-unset-breakpoint t] | 4416 | ["Unset Breakpoint" edebug-unset-breakpoint t] |
| 4417 | ["Unset Breakpoints In Form" edebug-unset-breakpoints t] | ||
| 4418 | ["Toggle Disable Breakpoint" edebug-toggle-disable-breakpoint t] | ||
| 4384 | ["Set Conditional Breakpoint" edebug-set-conditional-breakpoint t] | 4419 | ["Set Conditional Breakpoint" edebug-set-conditional-breakpoint t] |
| 4385 | ["Set Global Break Condition" edebug-set-global-break-condition t] | 4420 | ["Set Global Break Condition" edebug-set-global-break-condition t] |
| 4386 | ["Show Next Breakpoint" edebug-next-breakpoint t]) | 4421 | ["Show Next Breakpoint" edebug-next-breakpoint t]) |