diff options
| -rw-r--r-- | lisp/emacs-lisp/edebug.el | 75 |
1 files changed, 55 insertions, 20 deletions
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 41b473f6d3f..2f26fce27cb 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el | |||
| @@ -2241,8 +2241,10 @@ error is signaled again." | |||
| 2241 | 2241 | ||
| 2242 | ;; Save the outside value of executing macro. (here??) | 2242 | ;; Save the outside value of executing macro. (here??) |
| 2243 | (edebug-outside-executing-macro executing-kbd-macro) | 2243 | (edebug-outside-executing-macro executing-kbd-macro) |
| 2244 | (edebug-outside-pre-command-hook pre-command-hook) | 2244 | (edebug-outside-pre-command-hook |
| 2245 | (edebug-outside-post-command-hook post-command-hook)) | 2245 | (edebug-var-status 'pre-command-hook)) |
| 2246 | (edebug-outside-post-command-hook | ||
| 2247 | (edebug-var-status 'post-command-hook))) | ||
| 2246 | (unwind-protect | 2248 | (unwind-protect |
| 2247 | (let (;; Don't keep reading from an executing kbd macro | 2249 | (let (;; Don't keep reading from an executing kbd macro |
| 2248 | ;; within edebug unless edebug-continue-kbd-macro is | 2250 | ;; within edebug unless edebug-continue-kbd-macro is |
| @@ -2267,10 +2269,11 @@ error is signaled again." | |||
| 2267 | edebug-next-execution-mode nil) | 2269 | edebug-next-execution-mode nil) |
| 2268 | (edebug-enter edebug-function edebug-args edebug-body)) | 2270 | (edebug-enter edebug-function edebug-args edebug-body)) |
| 2269 | ;; Reset global variables in case outside value was changed. | 2271 | ;; Reset global variables in case outside value was changed. |
| 2270 | (setq executing-kbd-macro edebug-outside-executing-macro | 2272 | (setq executing-kbd-macro edebug-outside-executing-macro) |
| 2271 | pre-command-hook edebug-outside-pre-command-hook | 2273 | (edebug-restore-status |
| 2272 | post-command-hook edebug-outside-post-command-hook | 2274 | 'post-command-hook edebug-outside-post-command-hook) |
| 2273 | ))) | 2275 | (edebug-restore-status |
| 2276 | 'pre-command-hook edebug-outside-pre-command-hook))) | ||
| 2274 | 2277 | ||
| 2275 | (let* ((edebug-data (get edebug-function 'edebug)) | 2278 | (let* ((edebug-data (get edebug-function 'edebug)) |
| 2276 | (edebug-def-mark (car edebug-data)) ; mark at def start | 2279 | (edebug-def-mark (car edebug-data)) ; mark at def start |
| @@ -2291,6 +2294,30 @@ error is signaled again." | |||
| 2291 | (funcall edebug-body)) | 2294 | (funcall edebug-body)) |
| 2292 | ))) | 2295 | ))) |
| 2293 | 2296 | ||
| 2297 | (defun edebug-var-status (var) | ||
| 2298 | "Return a cons cell describing the status of VAR's current binding. | ||
| 2299 | The purpose of this function is so you can properly undo | ||
| 2300 | subsequent changes to the same binding, by passing the status | ||
| 2301 | cons cell to `edebug-restore-status'. The status cons cell | ||
| 2302 | has the form (LOCUS . VALUE), where LOCUS can be a buffer | ||
| 2303 | \(for a buffer-local binding), a frame (for a frame-local binding), | ||
| 2304 | or nil (if the default binding is current)." | ||
| 2305 | (cons (variable-binding-locus var) | ||
| 2306 | (symbol-value var))) | ||
| 2307 | |||
| 2308 | (defun edebug-restore-status (var status) | ||
| 2309 | "Reset VAR based on STATUS. | ||
| 2310 | STATUS should be a list you got from `edebug-var-status'." | ||
| 2311 | (let ((locus (car status)) | ||
| 2312 | (value (cdr status))) | ||
| 2313 | (cond ((bufferp locus) | ||
| 2314 | (if (buffer-live-p locus) | ||
| 2315 | (with-current-buffer locus | ||
| 2316 | (set var value)))) | ||
| 2317 | ((framep locus) | ||
| 2318 | (modify-frame-parameters locus (list (cons var value)))) | ||
| 2319 | (t | ||
| 2320 | (set var value))))) | ||
| 2294 | 2321 | ||
| 2295 | (defun edebug-enter-trace (edebug-body) | 2322 | (defun edebug-enter-trace (edebug-body) |
| 2296 | (let ((edebug-stack-depth (1+ edebug-stack-depth)) | 2323 | (let ((edebug-stack-depth (1+ edebug-stack-depth)) |
| @@ -3511,8 +3538,9 @@ Return the result of the last expression." | |||
| 3511 | 3538 | ||
| 3512 | (executing-kbd-macro edebug-outside-executing-macro) | 3539 | (executing-kbd-macro edebug-outside-executing-macro) |
| 3513 | (defining-kbd-macro edebug-outside-defining-kbd-macro) | 3540 | (defining-kbd-macro edebug-outside-defining-kbd-macro) |
| 3514 | (pre-command-hook edebug-outside-pre-command-hook) | 3541 | ;; Get the values out of the saved statuses. |
| 3515 | (post-command-hook edebug-outside-post-command-hook) | 3542 | (pre-command-hook (cdr edebug-outside-pre-command-hook)) |
| 3543 | (post-command-hook (cdr edebug-outside-post-command-hook)) | ||
| 3516 | 3544 | ||
| 3517 | ;; See edebug-display | 3545 | ;; See edebug-display |
| 3518 | (overlay-arrow-position edebug-outside-o-a-p) | 3546 | (overlay-arrow-position edebug-outside-o-a-p) |
| @@ -3552,13 +3580,18 @@ Return the result of the last expression." | |||
| 3552 | 3580 | ||
| 3553 | edebug-outside-executing-macro executing-kbd-macro | 3581 | edebug-outside-executing-macro executing-kbd-macro |
| 3554 | edebug-outside-defining-kbd-macro defining-kbd-macro | 3582 | edebug-outside-defining-kbd-macro defining-kbd-macro |
| 3555 | edebug-outside-pre-command-hook pre-command-hook | ||
| 3556 | edebug-outside-post-command-hook post-command-hook | ||
| 3557 | 3583 | ||
| 3558 | edebug-outside-o-a-p overlay-arrow-position | 3584 | edebug-outside-o-a-p overlay-arrow-position |
| 3559 | edebug-outside-o-a-s overlay-arrow-string | 3585 | edebug-outside-o-a-s overlay-arrow-string |
| 3560 | edebug-outside-c-i-e-a cursor-in-echo-area | 3586 | edebug-outside-c-i-e-a cursor-in-echo-area |
| 3561 | ))) ; let | 3587 | ) |
| 3588 | |||
| 3589 | ;; Restore the outside saved values; don't alter | ||
| 3590 | ;; the outside binding loci. | ||
| 3591 | (setcdr edebug-outside-pre-command-hook pre-command-hook) | ||
| 3592 | (setcdr edebug-outside-post-command-hook post-command-hook) | ||
| 3593 | |||
| 3594 | )) ; let | ||
| 3562 | )) | 3595 | )) |
| 3563 | 3596 | ||
| 3564 | (defvar cl-debug-env nil) ;; defined in cl; non-nil when lexical env used. | 3597 | (defvar cl-debug-env nil) ;; defined in cl; non-nil when lexical env used. |
| @@ -3676,14 +3709,13 @@ Print result in minibuffer." | |||
| 3676 | (edebug-safe-prin1-to-string (car values))))) | 3709 | (edebug-safe-prin1-to-string (car values))))) |
| 3677 | 3710 | ||
| 3678 | (defun edebug-eval-last-sexp () | 3711 | (defun edebug-eval-last-sexp () |
| 3679 | "Evaluate sexp before point in the outside environment; | 3712 | "Evaluate sexp before point in the outside environment; value in minibuffer." |
| 3680 | print value in minibuffer." | ||
| 3681 | (interactive) | 3713 | (interactive) |
| 3682 | (edebug-eval-expression (edebug-last-sexp))) | 3714 | (edebug-eval-expression (edebug-last-sexp))) |
| 3683 | 3715 | ||
| 3684 | (defun edebug-eval-print-last-sexp () | 3716 | (defun edebug-eval-print-last-sexp () |
| 3685 | "Evaluate sexp before point in the outside environment; | 3717 | "Evaluate sexp before point in the outside environment; insert the value. |
| 3686 | print value into current buffer." | 3718 | This prints the value into current buffer." |
| 3687 | (interactive) | 3719 | (interactive) |
| 3688 | (let* ((edebug-form (edebug-last-sexp)) | 3720 | (let* ((edebug-form (edebug-last-sexp)) |
| 3689 | (edebug-result-string | 3721 | (edebug-result-string |
| @@ -3698,12 +3730,15 @@ print value into current buffer." | |||
| 3698 | 3730 | ||
| 3699 | ;;; Edebug Minor Mode | 3731 | ;;; Edebug Minor Mode |
| 3700 | 3732 | ||
| 3701 | ;; Global GUD bindings for all emacs-lisp-mode buffers. | 3733 | (defvar gud-inhibit-global-bindings |
| 3702 | (define-key emacs-lisp-mode-map "\C-x\C-a\C-s" 'edebug-step-mode) | 3734 | "*Non-nil means don't do global rebindings of C-x C-a subcommands.") |
| 3703 | (define-key emacs-lisp-mode-map "\C-x\C-a\C-n" 'edebug-next-mode) | ||
| 3704 | (define-key emacs-lisp-mode-map "\C-x\C-a\C-c" 'edebug-go-mode) | ||
| 3705 | (define-key emacs-lisp-mode-map "\C-x\C-a\C-l" 'edebug-where) | ||
| 3706 | 3735 | ||
| 3736 | ;; Global GUD bindings for all emacs-lisp-mode buffers. | ||
| 3737 | (unless gud-inhibit-global-bindings | ||
| 3738 | (define-key emacs-lisp-mode-map "\C-x\C-a\C-s" 'edebug-step-mode) | ||
| 3739 | (define-key emacs-lisp-mode-map "\C-x\C-a\C-n" 'edebug-next-mode) | ||
| 3740 | (define-key emacs-lisp-mode-map "\C-x\C-a\C-c" 'edebug-go-mode) | ||
| 3741 | (define-key emacs-lisp-mode-map "\C-x\C-a\C-l" 'edebug-where)) | ||
| 3707 | 3742 | ||
| 3708 | (defvar edebug-mode-map | 3743 | (defvar edebug-mode-map |
| 3709 | (let ((map (copy-keymap emacs-lisp-mode-map))) | 3744 | (let ((map (copy-keymap emacs-lisp-mode-map))) |