From: Lars Ingebrigtsen Date: Sun, 20 Oct 2019 21:16:04 +0000 (+0200) Subject: Add a command to toggle an edebug breakpoint X-Git-Tag: emacs-27.0.90~941 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=78cb3791fa11c95756ee3917c63cfea774f128a2;p=emacs.git 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. --- 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: Set a breakpoint at the stop point at or after point (@code{edebug-set-breakpoint}). If you use a prefix argument, the breakpoint is temporary---it turns off the first time it stops the -program. An overlay with the @code{edebug-breakpoint} face is put at -the breakpoint. +program. An overlay with the @code{edebug-enabled-breakpoint} or +@code{edebug-disabled-breakpoint} faces is put at the breakpoint. @item u Unset the breakpoint (if any) at the stop point at or after @@ -508,6 +508,12 @@ point (@code{edebug-unset-breakpoint}). Unset any breakpoints in the current form (@code{edebug-unset-breakpoints}). +@item D +Toggle whether to disable the breakpoint near point +(@code{edebug-toggle-disable-breakpoint}). This command is mostly +useful if the breakpoint is conditional and it would take some work to +recreate the condition. + @item x @var{condition} @key{RET} Set a conditional breakpoint which stops the program only if evaluating @var{condition} produces a non-@code{nil} value diff --git a/etc/NEWS b/etc/NEWS index 46ed40dfcba..d9a9fd82a61 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1462,9 +1462,17 @@ the Elisp manual for documentation of the new mode and its commands. ** Edebug -*** New face 'edebug-breakpoint' -When setting breakpoints in Edebug, an overlay with this face is -placed over the point in question. ++++ +*** New faces 'edebug-enabled-breakpoint' and 'edebug-disabled-breakpoint' +When setting breakpoints in Edebug, an overlay with these faces are +placed over the point in question, depending on whether they are +enabled or not. + ++++ +*** New command 'edebug-toggle-disable-breakpoint' +This command allows you to disable a breakpoint temporarily. This is +mainly useful with breakpoints that are conditional and would take +some time to recreate. +++ *** 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 @@ "A source-level debugger for Emacs Lisp." :group 'lisp) -(defface edebug-breakpoint '((t :inherit highlight)) - "Face used to mark breakpoints." +(defface edebug-enabled-breakpoint '((t :inherit highlight)) + "Face used to mark enabled breakpoints." + :version "27.1") + +(defface edebug-disabled-breakpoint + '((((class color) (min-colors 88) (background light)) + :background "#ddffdd" :extend t) + (((class color) (min-colors 88) (background dark)) + :background "#335533" :extend t)) + "Face used to mark disabled breakpoints." :version "27.1") (defcustom edebug-setup-hook nil @@ -2536,6 +2544,7 @@ See `edebug-behavior-alist' for implementations.") (edebug-breakpoints (car (cdr edebug-data))) ; list of breakpoints (edebug-break-data (assq offset-index edebug-breakpoints)) (edebug-break-condition (car (cdr edebug-break-data))) + (breakpoint-disabled (nth 4 edebug-break-data)) (edebug-global-break (if edebug-global-break-condition (condition-case nil @@ -2549,6 +2558,7 @@ See `edebug-behavior-alist' for implementations.") (setq edebug-break (or edebug-global-break (and edebug-break-data + (not breakpoint-disabled) (or (not edebug-break-condition) (setq edebug-break-result (edebug-eval edebug-break-condition)))))) @@ -3206,7 +3216,8 @@ the breakpoint." (edebug-sort-alist (cons (list index condition temporary - (set-marker (make-marker) position)) + (set-marker (make-marker) position) + nil) edebug-breakpoints) '<)) (if condition @@ -3236,7 +3247,10 @@ the breakpoint." (let* ((pos (+ start (aref offsets (car breakpoint)))) (overlay (make-overlay pos (1+ pos)))) (overlay-put overlay 'edebug t) - (overlay-put overlay 'face 'edebug-breakpoint)))))) + (overlay-put overlay 'face + (if (nth 4 breakpoint) + 'edebug-disabled-breakpoint + 'edebug-enabled-breakpoint))))))) (defun edebug--overlay-breakpoints-remove (start end) (dolist (overlay (overlays-in start end)) @@ -3271,6 +3285,22 @@ With prefix argument, make it a temporary breakpoint." (goto-char (nth 3 breakpoint)) (edebug-modify-breakpoint nil))))) +(defun edebug-toggle-disable-breakpoint () + "Toggle whether the breakpoint near point is disabled." + (interactive) + (let ((stop-point (edebug-find-stop-point))) + (unless stop-point + (user-error "No stop point near point")) + (let* ((name (car stop-point)) + (index (cdr stop-point)) + (data (get name 'edebug)) + (breakpoint (assq index (nth 1 data)))) + (unless breakpoint + (user-error "No breakpoint near point")) + (setf (nth 4 breakpoint) + (not (nth 4 breakpoint))) + (edebug--overlay-breakpoints name)))) + (defun edebug-set-global-break-condition (expression) "Set `edebug-global-break-condition' to EXPRESSION." (interactive @@ -3779,6 +3809,7 @@ be installed in `emacs-lisp-mode-map'.") (define-key map "B" 'edebug-next-breakpoint) (define-key map "x" 'edebug-set-conditional-breakpoint) (define-key map "X" 'edebug-set-global-break-condition) + (define-key map "D" 'edebug-toggle-disable-breakpoint) ;; evaluation (define-key map "r" 'edebug-previous-result) @@ -3834,8 +3865,10 @@ be installed in `emacs-lisp-mode-map'.") ;; breakpoints (define-key map "b" 'edebug-set-breakpoint) (define-key map "u" 'edebug-unset-breakpoint) + (define-key map "U" 'edebug-unset-breakpoints) (define-key map "x" 'edebug-set-conditional-breakpoint) (define-key map "X" 'edebug-set-global-break-condition) + (define-key map "D" 'edebug-toggle-disable-breakpoint) ;; views (define-key map "w" 'edebug-where) @@ -4381,6 +4414,8 @@ It is removed when you hit any char." ("Breaks" ["Set Breakpoint" edebug-set-breakpoint t] ["Unset Breakpoint" edebug-unset-breakpoint t] + ["Unset Breakpoints In Form" edebug-unset-breakpoints t] + ["Toggle Disable Breakpoint" edebug-toggle-disable-breakpoint t] ["Set Conditional Breakpoint" edebug-set-conditional-breakpoint t] ["Set Global Break Condition" edebug-set-global-break-condition t] ["Show Next Breakpoint" edebug-next-breakpoint t])