diff options
| author | Lute Kamstra | 2005-03-01 09:08:47 +0000 |
|---|---|---|
| committer | Lute Kamstra | 2005-03-01 09:08:47 +0000 |
| commit | 07f3fdb1d14cef5b1f59a322e0587e5c9526a749 (patch) | |
| tree | 5ace2bc768e9675f16b121b2e77c5e71fdcc5f04 | |
| parent | a1f74898ea7d3f89b4a8e4a3ea10d42246a3075f (diff) | |
| download | emacs-07f3fdb1d14cef5b1f59a322e0587e5c9526a749.tar.gz emacs-07f3fdb1d14cef5b1f59a322e0587e5c9526a749.zip | |
(debug-on-entry-1): Reimplement to make sure that debug-entry-code can
be safely removed from a function while this code is being evaluated.
Revert the 2005-02-27 change as the new implementation no longer
requires it. Make sure that a function body containing just a string
is not mistaken for a docstring.
| -rw-r--r-- | lisp/emacs-lisp/debug.el | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index 06efa93f33f..fe642a276e8 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | ;;; Commentary: | 26 | ;;; Commentary: |
| 27 | 27 | ||
| 28 | ;; This is a major mode documented in the Emacs manual. | 28 | ;; This is a major mode documented in the Emacs Lisp manual. |
| 29 | 29 | ||
| 30 | ;;; Code: | 30 | ;;; Code: |
| 31 | 31 | ||
| @@ -479,8 +479,6 @@ Applies to the frame whose line point is on in the backtrace." | |||
| 479 | (insert ? ))) | 479 | (insert ? ))) |
| 480 | (beginning-of-line)) | 480 | (beginning-of-line)) |
| 481 | 481 | ||
| 482 | |||
| 483 | |||
| 484 | (put 'debugger-env-macro 'lisp-indent-function 0) | 482 | (put 'debugger-env-macro 'lisp-indent-function 0) |
| 485 | (defmacro debugger-env-macro (&rest body) | 483 | (defmacro debugger-env-macro (&rest body) |
| 486 | "Run BODY in original environment." | 484 | "Run BODY in original environment." |
| @@ -694,7 +692,6 @@ If argument is nil or an empty string, cancel for all functions." | |||
| 694 | (setq body (cons (documentation function) body))) | 692 | (setq body (cons (documentation function) body))) |
| 695 | (fset function (cons 'lambda (cons (car contents) body))))))) | 693 | (fset function (cons 'lambda (cons (car contents) body))))))) |
| 696 | 694 | ||
| 697 | |||
| 698 | (defconst debug-entry-code '(if inhibit-debug-on-entry nil (debug 'debug)) | 695 | (defconst debug-entry-code '(if inhibit-debug-on-entry nil (debug 'debug)) |
| 699 | "Code added to a function to cause it to call the debugger upon entry.") | 696 | "Code added to a function to cause it to call the debugger upon entry.") |
| 700 | 697 | ||
| @@ -705,22 +702,18 @@ If argument is nil or an empty string, cancel for all functions." | |||
| 705 | (debug-on-entry-1 function (cdr defn) flag) | 702 | (debug-on-entry-1 function (cdr defn) flag) |
| 706 | (or (eq (car defn) 'lambda) | 703 | (or (eq (car defn) 'lambda) |
| 707 | (error "%s not user-defined Lisp function" function)) | 704 | (error "%s not user-defined Lisp function" function)) |
| 708 | (let ((tail (cddr defn))) | 705 | (let ((tail (cdr defn))) |
| 709 | ;; Skip the docstring. | 706 | ;; Skip the docstring. |
| 710 | (if (stringp (car tail)) (setq tail (cdr tail))) | 707 | (when (and (stringp (cadr tail)) (cddr tail)) |
| 708 | (setq tail (cdr tail))) | ||
| 711 | ;; Skip the interactive form. | 709 | ;; Skip the interactive form. |
| 712 | (if (eq 'interactive (car-safe (car tail))) (setq tail (cdr tail))) | 710 | (when (eq 'interactive (car-safe (cadr tail))) |
| 713 | (unless (eq flag (equal (car tail) debug-entry-code)) | 711 | (setq tail (cdr tail))) |
| 714 | ;; If the function has no body, add nil as a body element. | 712 | (unless (eq flag (equal (cadr tail) debug-entry-code)) |
| 715 | (when (null tail) | ||
| 716 | (setq tail (list nil)) | ||
| 717 | (nconc defn tail)) | ||
| 718 | ;; Add/remove debug statement as needed. | 713 | ;; Add/remove debug statement as needed. |
| 719 | (if (not flag) | 714 | (if flag |
| 720 | (progn (setcar tail (cadr tail)) | 715 | (setcdr tail (cons debug-entry-code (cdr tail))) |
| 721 | (setcdr tail (cddr tail))) | 716 | (setcdr tail (cddr tail)))) |
| 722 | (setcdr tail (cons (car tail) (cdr tail))) | ||
| 723 | (setcar tail debug-entry-code))) | ||
| 724 | defn)))) | 717 | defn)))) |
| 725 | 718 | ||
| 726 | (defun debugger-list-functions () | 719 | (defun debugger-list-functions () |