Commits

Anonymous committed d3f3cfa

* edebug.el: Synch with GNU Emacs 20.6.
Daiki's patch "[edebug] Synch with GNU Emacs 20.6",
<87itxbdak0.fsf@mail.unixuser.org>

  • Participants
  • Parent commits 3c82a51

Comments (0)

Files changed (2)

+2000-04-21   Daiki Ueno  <ueno@unixuser.org>
+
+	* edebug.el: Synch with GNU Emacs 20.6.
+
 1999-12-05  Andreas Jaeger  <aj@suse.de>
 
 	* edebug-test.el (test): Replace obsolete allocate-event with
 ;;; edebug.el --- a source-level debugger for Emacs Lisp
 
-;; Copyright (C) 1988,'89,'90,'91,'92,'93,'94,'95 Free Software Foundation, Inc
-
-;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
+;; Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 97, 1999
+;;       Free Software Foundation, Inc.
+
+;; Author: Daniel LaLiberte <liberte@hypernews.org>
+;; Maintainer: FSF
 ;; Keywords: lisp, tools, maint
 
 ;; This file is part of XEmacs.
 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 ;; 02111-1307, USA.
 
-;;; Synched up with: FSF 19.34.
+;;; Synched up with: FSF 20.6.
 
 ;;; Commentary:
 
-;; LCD Archive Entry:
-;; edebug|Daniel LaLiberte|liberte@cs.uiuc.edu
-;; |A source level debugger for Emacs Lisp.
-;; |$Date$|$Revision$|~/modes/edebug.el|
-
 ;; This minor mode allows programmers to step through Emacs Lisp
 ;; source code while executing functions.  You can also set
 ;; breakpoints, trace (stopping at each expression), evaluate
 ;; expressions, trap errors normally caught by debug, and display a
 ;; debug style backtrace.
 
-;;; Installation
-;; =============
-
-;; Put edebug.el in some directory in your load-path and
-;; byte-compile it.  Also read the beginning of edebug-epoch.el, 
-;; cl-specs.el, and edebug-cl-read.el if they apply to you.
-
-;; Unless you are using Emacs 19 which is already set up to use Edebug,
-;; put the following forms in your .emacs file.
-;; (define-key emacs-lisp-mode-map "\C-xx" 'edebug-eval-top-level-form)
-;; (autoload 'edebug-eval-top-level-form "edebug")
+;;; Minimal Instructions
+;; =====================
+
+;; First evaluate a defun with C-M-x, then run the function.  Step
+;; through the code with SPC, mark breakpoints with b, go until a
+;; breakpoint is reached with g, and quit execution with q.  Use the
+;; "?" command in edebug to describe other commands. 
+;; See the Emacs Lisp Reference Manual for more details.
 
 ;; If you wish to change the default edebug global command prefix, change:
 ;; (setq edebug-global-prefix "\C-xX")
 
-;; Other options, are described in the manual.
-
-;; In previous versions of Edebug, users were directed to set
-;; `debugger' to `edebug-debug'.  This is no longer necessary
-;; since Edebug automatically sets it whenever Edebug is active.
-
-;;; Minimal Instructions
-;; =====================
-
-;; First evaluate a defun with C-xx, then run the function.  Step
-;; through the code with SPC, mark breakpoints with b, go until a
-;; breakpoint is reached with g, and quit execution with q.  Use the
-;; "?" command in edebug to describe other commands.  See edebug.tex
-;; or the Emacs 19 Lisp Reference Manual for more instructions.
-
-;; Send me your enhancements, ideas, bugs, or fixes.
-;; For bugs, you can call edebug-submit-bug-report if you have reporter.el.
-;; There is an edebug mailing list if you want to keep up
-;; with the latest developments. Requests to: edebug-request@cs.uiuc.edu
-
-;; Daniel LaLiberte   217-398-4114
-;; University of Illinois, Urbana-Champaign
-;; Department of Computer Science
-;; 1304 W Springfield
-;; Urbana, IL  61801
-
-;; uiucdcs!liberte
-;; liberte@cs.uiuc.edu
-
-;; For the early revision history, see edebug-history.
+;; Edebug was written by
+;; Daniel LaLiberte
+;; GTE Labs
+;; 40 Sylvan Rd
+;; Waltham, MA  02254
+;; dlaliberte@gte.com
 
 ;;; Code:
 
 (defconst edebug-version
-  (let ((raw-version "$Revision$"))
-    (substring raw-version (string-match "[0-9.]*" raw-version)
-	       (match-end 0))))
-     
-(require 'backquote)
-
-;; Emacs 18 doesn't have defalias.
-(eval-and-compile
-  (or (fboundp 'defalias) (fset 'defalias 'fset)))
-
+  (concat "In Emacs version " emacs-version))
 
 ;;; Bug reporting
 
-(defconst edebug-maintainer-address "liberte@cs.uiuc.edu")
+(defconst edebug-maintainer-address "bug-gnu-emacs@gnu.org")
 
 (defun edebug-submit-bug-report ()
   "Submit, via mail, a bug report on edebug."
                'edebug-all-defs
                'edebug-all-forms
                'edebug-eval-macro-args
-               'edebug-stop-before-symbols
                'edebug-save-windows
                'edebug-save-displayed-buffer-points
                'edebug-initial-mode
   :group 'lisp)
 
 
-(defvar edebug-setup-hook nil
+(defcustom edebug-setup-hook nil
   "*Functions to call before edebug is used.
 Each time it is set to a new value, Edebug will call those functions
 once and then `edebug-setup-hook' is reset to nil.  You could use this
 to load up Edebug specifications associated with a package you are
-using but only when you also use Edebug.")
-
+using but only when you also use Edebug."
+  :type 'hook
+  :group 'edebug)
+
+;; edebug-all-defs and edebug-all-forms need to be autoloaded
+;; because the byte compiler binds them; as a result, if edebug
+;; is first loaded for a require in a compilation, they will be left unbound.
+
+;;;###autoload
 (defcustom edebug-all-defs nil
   "*If non-nil, evaluation of any defining forms will instrument for Edebug.
 This applies to `eval-defun', `eval-region', `eval-buffer', and
   :type 'boolean
   :group 'edebug)
 
+;; edebug-all-defs and edebug-all-forms need to be autoloaded
+;; because the byte compiler binds them; as a result, if edebug
+;; is first loaded for a require in a compilation, they will be left unbound.
+
+;;;###autoload
 (defcustom edebug-all-forms nil
   "*Non-nil evaluation of all forms will instrument for Edebug.
 This doesn't apply to loading or evaluations in the minibuffer.
 macro call arguments as if they will be evaluated.  
 For each macro, a `edebug-form-spec' overrides this option.
 So to specify exceptions for macros that have some arguments evaluated
-and some not, you should specify an `edebug-form-spec'.
-
-This option is going away soon."
-  :type 'boolean
-  :group 'edebug)
-
-(defcustom edebug-stop-before-symbols nil
-  "*Non-nil causes Edebug to stop before symbols as well as after.  
-In any case, a breakpoint or interrupt may stop before a symbol.
-
-This option is going away soon."
+and some not, you should specify an `edebug-form-spec'."
   :type 'boolean
   :group 'edebug)
 
   :type '(choice (const step) (const next) (const go)
 		 (const Go-nonstop) (const trace)
 		 (const Trace-fast) (const continue)
-		 (const continue-fast))
+		 (const Continue-fast))
   :group 'edebug)
 
 (defcustom edebug-trace nil
 handled by a `condition-case'.  This option is useful for debugging
 signals that *are* handled since they would otherwise be missed.
 After execution is resumed, the error is signaled again."
-  :type '(choice boolean (repeat string))
+  :type '(choice (const :tag "off")
+		 (repeat :menu-tag "When"
+			 :value (nil)
+			 (symbol :format "%v"))
+		 (const :tag "always" t))
   :group 'edebug)
 
 (defcustom edebug-on-quit t
   :type 'sexp
   :group 'edebug)
 
+(defcustom edebug-sit-for-seconds 1
+  "*Number of seconds to pause when execution mode is `trace'."
+  :type 'number
+  :group 'edebug)
+
 ;;; Form spec utilities.
 
 ;;;###autoload
 	  (let ((edebug-all-forms edebugging)
 		(edebug-all-defs (eq edebug-all-defs (not edebug-it))))
 	    (edebug-read-top-level-form))))
-    (if (and (eq (car form) 'defvar)
-	     (cdr-safe (cdr-safe form)))
-	(setq form (cons 'defconst (cdr form))))
+    (cond ((and (eq (car form) 'defvar)
+		(cdr-safe (cdr-safe form)))
+	   ;; Force variable to be bound.
+	   (setq form (cons 'defconst (cdr form))))
+	  ((and (eq (car form) 'defcustom)
+		(default-boundp (nth 1 form)))
+	   ;; Force variable to be bound.
+	   (set-default (nth 1 form) (eval (nth 2 form)))))
     (setq edebug-result (eval form))
     (if (not edebugging)
 	(princ edebug-result)
   ;; lparen, rparen, dot, quote, backquote, comma, string, char, vector,
   ;; or symbol.
   (edebug-skip-whitespace)
-  (let ((c (following-char)))
-    (if (> c 255)
-	'symbol
-      (aref edebug-read-syntax-table c))))
+  (if (or (> (following-char) 255)
+	  (and (eq (following-char) ?.)
+	       (save-excursion
+		 (forward-char 1)
+		 (and (>= (following-char) ?0)
+		      (<= (following-char) ?9)))))
+      'symbol
+    (aref edebug-read-syntax-table (following-char))))
 
 
 (defun edebug-skip-whitespace ()
     (cond
      ;; read goes one too far if a (possibly quoted) string or symbol
      ;; is immediately followed by non-whitespace.
-     ((eq class 'symbol) (prog1
-			     (edebug-original-read (current-buffer))
-			   (if (not (or (> (preceding-char) 255)
-					(eq (aref edebug-read-syntax-table 
-						  (preceding-char)) 'symbol)))
-			       (forward-char -1))))
-     ((eq class 'string) (prog1
-			     (edebug-original-read (current-buffer))
-			   (if (/= (preceding-char) ?\")
-			       (forward-char -1))))
+     ((eq class 'symbol) (edebug-original-read (current-buffer)))
+     ((eq class 'string) (edebug-original-read (current-buffer)))
      ((eq class 'quote) (forward-char 1)
       (list 'quote (edebug-read-sexp)))
      ((eq class 'backquote)
       )))
 
 (defun edebug-read-symbol (stream)
-  (prog1
-      (edebug-original-read stream)
-    ;; loses for escaped chars
-    (if (not (or (> (preceding-char) 255)
-		 (eq (aref edebug-read-syntax-table 
-			   (preceding-char)) 'symbol)))
-	(forward-char -1))))
+  (edebug-original-read stream))
 
 (defun edebug-read-string (stream)
-  (prog1
-      (edebug-original-read stream)
-    (if (/= (preceding-char) ?\")
-	(forward-char -1))))
+  (edebug-original-read stream))
 
 (defun edebug-read-quote (stream)
   ;; Turn 'thing into (quote thing)
   ;; Here we just catch any no-match not caught below and signal an error.
 
   ;; Run the setup hook.
+  ;; If it gets an error, make it nil.
   (let ((temp-hook edebug-setup-hook))
     (setq edebug-setup-hook nil)
     (run-hooks 'temp-hook))
   ;; given FORM.  Looks like: 
   ;; (edebug-after (edebug-before BEFORE-INDEX) AFTER-INDEX FORM)
   ;; Also increment the offset index for subsequent use.
-  ;; if (not edebug-stop-before-symbols) and form is a symbol,
-  ;; then don't call edebug-before.
   (list 'edebug-after 
 	(list 'edebug-before before-index)
 	after-index form))
 		(and (fboundp 'edebug-keywordp) (edebug-keywordp form)))
 	    form)
 
-	   ;; This option may go away.
-	   (edebug-stop-before-symbols
-	    (edebug-make-before-and-after-form 
-	     (edebug-inc-offset (car offset))
-	     form
-	     (edebug-inc-offset (cdr offset))
-	     ))
-
 	   (t ;; just a variable
 	    (edebug-make-after-form form (edebug-inc-offset (cdr offset))))))
 
 (def-edebug-spec condition-case
   (symbolp
    form
-   &rest (symbolp body)))
+   &rest ([&or symbolp (&rest symbolp)] body)))
 
 
 (def-edebug-spec \` (backquote-form))
 (def-edebug-spec save-match-data t)
 (def-edebug-spec with-output-to-string t)
 (def-edebug-spec with-current-buffer t)
+(def-edebug-spec combine-after-change-calls t)
 (def-edebug-spec with-temp-file t)
 (def-edebug-spec with-temp-buffer t)
+(def-edebug-spec with-temp-message t)
 
 ;; Anything else?
 
 (defvar edebug-outside-debug-on-error) ; the value of debug-on-error outside
 (defvar edebug-outside-debug-on-quit) ; the value of debug-on-quit outside
 
+(defvar edebug-outside-overriding-local-map)
+(defvar edebug-outside-overriding-terminal-local-map)
+
 (defvar edebug-outside-pre-command-hook)
 (defvar edebug-outside-post-command-hook)
-(defvar edebug-outside-post-command-idle-hook)
-
-;; Emacs 19
-(defvar pre-command-hook nil)
-(defvar post-command-hook nil)
-(defvar post-command-idle-hook nil)
 
 (defvar cl-lexical-debug)  ;; Defined in cl.el
 
 ;;; Handling signals
 
-(if (not (fboundp 'edebug-original-signal))
-    (defalias 'edebug-original-signal (symbol-function 'signal)))
-;; We should use advise for this!!
-
 (defun edebug-signal (edebug-signal-name edebug-signal-data)
   "Signal an error.  Args are SIGNAL-NAME, and associated DATA.
 A signal name is a symbol with an `error-conditions' property
       (edebug 'error (cons edebug-signal-name edebug-signal-data)))
   ;; If we reach here without another non-local exit, then send signal again.
   ;; i.e. the signal is not continuable, yet.
-  (edebug-original-signal edebug-signal-name edebug-signal-data))
-  
+  ;; Avoid infinite recursion.
+  (let ((signal-hook-function nil))
+    (signal edebug-signal-name edebug-signal-data)))
 
 ;;; Entering Edebug
 
 	    ;; Lexical bindings must be uncompiled for this to work.
 	    (cl-lexical-debug t)
 
+	    (edebug-outside-overriding-local-map overriding-local-map)
+	    (edebug-outside-overriding-terminal-local-map
+	     overriding-terminal-local-map)
+
 	    ;; Save the outside value of executing macro.  (here??)
 	    (edebug-outside-executing-macro executing-kbd-macro)
 	    (edebug-outside-pre-command-hook pre-command-hook)
-	    (edebug-outside-post-command-hook post-command-hook)
-	    (edebug-outside-post-command-idle-hook post-command-idle-hook))
+	    (edebug-outside-post-command-hook post-command-hook))
 	(unwind-protect
 	    (let (;; Don't keep reading from an executing kbd macro
 		  ;; within edebug unless edebug-continue-kbd-macro is
 		  (executing-kbd-macro 
 		   (if edebug-continue-kbd-macro executing-kbd-macro))
 
+		  ;; Don't get confused by the user's keymap changes.
+		  (overriding-local-map nil)
+		  (overriding-terminal-local-map nil)
+
+		  (signal-hook-function 'edebug-signal)
+
 		  ;; Disable command hooks.  This is essential when
 		  ;; a hook function is instrumented - to avoid infinite loop.
 		  ;; This may be more than we need, however.
 		  (pre-command-hook nil)
-		  (post-command-hook nil)
-		  (post-command-idle-hook nil))
+		  (post-command-hook nil))
 	      (setq edebug-execution-mode (or edebug-next-execution-mode 
 					      edebug-initial-mode 
 					      edebug-execution-mode)
 		    edebug-next-execution-mode nil)
-	      ;; Bind signal to edebug-signal only while Edebug is active.
-	      (fset 'signal 'edebug-signal)
-	      (unwind-protect
-		  (edebug-enter edebug-function edebug-args edebug-body)
-		(fset 'signal (symbol-function 'edebug-original-signal))))
+	      (edebug-enter edebug-function edebug-args edebug-body))
 	  ;; Reset global variables in case outside value was changed.
 	  (setq executing-kbd-macro edebug-outside-executing-macro
 		pre-command-hook edebug-outside-pre-command-hook
 		post-command-hook edebug-outside-post-command-hook
-		post-command-idle-hook edebug-outside-post-command-idle-hook
 		)))
     
     (let* ((edebug-data (get edebug-function 'edebug))
 	     (t (setq edebug-stop t))))
 	   ;; not edebug-break
 	   ((eq edebug-execution-mode 'trace)
-	    (edebug-sit-for 1))		; Force update and pause.
+	    (edebug-sit-for edebug-sit-for-seconds)) ; Force update and pause.
 	   ((eq edebug-execution-mode 'Trace-fast)
 	    (edebug-sit-for 0))		; Force update and continue.
 	   )
 	      (message "Break"))
 
 	  (setq buffer-read-only t)
-	  (fset 'signal (symbol-function 'edebug-original-signal))
+	  (setq signal-hook-function nil)
 
 	  (edebug-mode)
 	  (unwind-protect
 	      (recursive-edit)		;  <<<<<<<<<< Recursive edit
 
 	    ;; Do the following, even if quit occurs.
-	    (fset 'signal 'edebug-signal)
+	    (setq signal-hook-function 'edebug-signal)
 	    (if edebug-backtrace-buffer
 		(kill-buffer edebug-backtrace-buffer))
 	    ;; Could be an option to keep eval display up.
 	    ;; Remember selected-window after recursive-edit.
 	    ;;      (setq edebug-inside-window (selected-window))
 
-	    (store-match-data edebug-outside-match-data)
+	    (set-match-data edebug-outside-match-data)
 
 	    ;; Recursive edit may have changed buffers,
 	    ;; so set it back before exiting let.
 
        (set-buffer edebug-buffer)  ; why?
        ;; (use-local-map edebug-outside-map)
-       (store-match-data edebug-outside-match-data)
+       (set-match-data edebug-outside-match-data)
        ;; Restore outside context.
        (let (;; (edebug-inside-map (current-local-map)) ;; restore map??
 	     (last-command-char edebug-outside-last-command-char)
 	     (defining-kbd-macro edebug-outside-defining-kbd-macro)
 	     (pre-command-hook edebug-outside-pre-command-hook)
 	     (post-command-hook edebug-outside-post-command-hook)
-	     (post-command-idle-hook edebug-outside-post-command-idle-hook)
 
 	     ;; See edebug-display
 	     (overlay-arrow-position edebug-outside-o-a-p)
 	    edebug-outside-defining-kbd-macro defining-kbd-macro
 	    edebug-outside-pre-command-hook pre-command-hook
 	    edebug-outside-post-command-hook post-command-hook
-	    edebug-outside-post-command-idle-hook post-command-idle-hook
 
 	    edebug-outside-o-a-p overlay-arrow-position
 	    edebug-outside-o-a-s overlay-arrow-string
 
 (defun edebug-compute-previous-result (edebug-previous-value)
   (setq edebug-previous-result
-	(if (numberp edebug-previous-value)
-	    (format "Result: %s" edebug-previous-value)
+	(if (and (integerp edebug-previous-value)
+		 (< edebug-previous-value 256)
+		 (>= edebug-previous-value 0))
+	    (format "Result: %s = %s" edebug-previous-value
+		    (single-key-description edebug-previous-value))
 	  (if edebug-unwrap-results
 	      (setq edebug-previous-value 
 		    (edebug-unwrap* edebug-previous-value)))
 
 
 (defvar edebug-eval-mode-map nil
-  "Keymap for edebug-eval-mode.  Superset of lisp-interaction-mode.")
+  "Keymap for Edebug Eval mode.  Superset of Lisp Interaction mode.")
 
 (if edebug-eval-mode-map
     nil
   (define-key edebug-eval-mode-map "\C-j" 'edebug-eval-print-last-sexp)
   )
 
+(put 'edebug-eval-mode 'mode-class 'special)
 
 (defun edebug-eval-mode ()
   "Mode for evaluation list buffer while in Edebug.
 "
   (lisp-interaction-mode)
   (setq major-mode 'edebug-eval-mode)
-  (setq mode-name "Edebug-Eval")
+  (setq mode-name "Edebug Eval")
   (use-local-map edebug-eval-mode-map))
 
 ;;; Interface with standard debugger.
 ;;; The default for all above is Emacs 18, because it is easier to compile
 ;;; Emacs 18 code in Emacs 19 than vice versa.  This default will
 ;;; change once most people are using Emacs 19 or derivatives.
- 
+
 ;; Epoch specific code is in a separate file: edebug-epoch.el.
 
 ;; The byte-compiler will complain about changes in number of arguments
   (defun edebug-mark ()
     (mark t));; Does this work for XEmacs too?
 
-  ;; Use minibuffer-history when reading expressions.
-  (defvar read-expression-history) ;; hush bytecomp
-  (defvar read-expression-map)
-
   (defun edebug-set-conditional-breakpoint (arg condition)
     "Set a conditional breakpoint at nearest sexp.
 The condition is evaluated in the outside context.
      edebug-sit-for
      edebug-prin1-to-string 
      edebug-format
-     edebug-original-signal
      ;; XEmacs
      zmacs-deactivate-region
      popup-menu