Refill some copyright headers.
[bpt/emacs.git] / lisp / emacs-lisp / edebug.el
index ad740e0..1af2252 100644 (file)
@@ -1,8 +1,8 @@
 ;;; edebug.el --- a source-level debugger for Emacs Lisp
 
-;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999,
-;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997,
+;;   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+;;   2010, 2011  Free Software Foundation, Inc.
 
 ;; Author: Daniel LaLiberte <liberte@holonexus.org>
 ;; Maintainer: FSF
@@ -352,8 +352,7 @@ Return the result of the last expression in BODY."
         (edebug:s-r-end (point-max-marker)))
      (unwind-protect
         (progn ,@body)
-       (save-excursion
-        (set-buffer (marker-buffer edebug:s-r-beg))
+       (with-current-buffer (marker-buffer edebug:s-r-beg)
         (narrow-to-region edebug:s-r-beg edebug:s-r-end)))))
 
 ;;; Display
@@ -886,17 +885,12 @@ already is one.)"
    (edebug-storing-offsets (1- (point)) 'quote)
    (edebug-read-storing-offsets stream)))
 
-(defvar edebug-read-backquote-level 0
-  "If non-zero, we're in a new-style backquote.
-It should never be negative.  This controls how we read comma constructs.")
-
 (defun edebug-read-backquote (stream)
   ;; Turn `thing into (\` thing)
   (forward-char 1)
   (list
    (edebug-storing-offsets (1- (point)) '\`)
-   (let ((edebug-read-backquote-level (1+ edebug-read-backquote-level)))
-     (edebug-read-storing-offsets stream))))
+   (edebug-read-storing-offsets stream)))
 
 (defun edebug-read-comma (stream)
   ;; Turn ,thing into (\, thing).  Handle ,@ and ,. also.
@@ -911,12 +905,9 @@ It should never be negative.  This controls how we read comma constructs.")
             (forward-char 1)))
       ;; Generate the same structure of offsets we would have
       ;; if the resulting list appeared verbatim in the input text.
-      (if (zerop edebug-read-backquote-level)
-         (edebug-storing-offsets opoint symbol)
-       (list
-        (edebug-storing-offsets opoint symbol)
-        (let ((edebug-read-backquote-level (1- edebug-read-backquote-level)))
-          (edebug-read-storing-offsets stream)))))))
+      (list
+       (edebug-storing-offsets opoint symbol)
+       (edebug-read-storing-offsets stream)))))
 
 (defun edebug-read-function (stream)
   ;; Turn #'thing into (function thing)
@@ -938,17 +929,7 @@ It should never be negative.  This controls how we read comma constructs.")
   (prog1
       (let ((elements))
        (while (not (memq (edebug-next-token-class) '(rparen dot)))
-         (if (and (eq (edebug-next-token-class) 'backquote)
-                  (null elements)
-                  (zerop edebug-read-backquote-level))
-             (progn
-               ;; Old style backquote.
-               (forward-char 1)        ; Skip backquote.
-               ;; Call edebug-storing-offsets here so that we
-               ;; produce the same offsets we would have had
-               ;; if the backquote were an ordinary symbol.
-               (push (edebug-storing-offsets (1- (point)) '\`) elements))
-           (push (edebug-read-storing-offsets stream) elements)))
+          (push (edebug-read-storing-offsets stream) elements))
        (setq elements (nreverse elements))
        (if (eq 'dot (edebug-next-token-class))
            (let (dotted-form)
@@ -2150,8 +2131,6 @@ expressions; a `progn' form will be returned enclosing these forms."
 
 (def-edebug-spec with-custom-print body)
 
-(def-edebug-spec sregexq (&rest sexp))
-(def-edebug-spec rx (&rest sexp))
 
 ;;; The debugger itself
 
@@ -2579,15 +2558,16 @@ MSG is printed after `::::} '."
        (edebug-outside-o-a-p overlay-arrow-position)
        (edebug-outside-o-a-s overlay-arrow-string)
        (edebug-outside-c-i-e-a cursor-in-echo-area)
-       (edebug-outside-d-c-i-n-s-w default-cursor-in-non-selected-windows))
+       (edebug-outside-d-c-i-n-s-w
+         (default-value 'cursor-in-non-selected-windows)))
     (unwind-protect
        (let ((overlay-arrow-position overlay-arrow-position)
              (overlay-arrow-string overlay-arrow-string)
              (cursor-in-echo-area nil)
-             (default-cursor-in-non-selected-windows t)
              (unread-command-events unread-command-events)
              ;; any others??
              )
+          (setq-default cursor-in-non-selected-windows t)
          (if (not (buffer-name edebug-buffer))
              (let ((debug-on-error nil))
                (error "Buffer defining %s not found" edebug-function)))
@@ -2782,10 +2762,8 @@ MSG is printed after `::::} '."
          ;; Restore edebug-buffer's outside point.
          ;;    (edebug-trace "restore edebug-buffer point: %s"
          ;;              edebug-buffer-outside-point)
-         (let ((current-buffer (current-buffer)))
-           (set-buffer edebug-buffer)
-           (goto-char edebug-buffer-outside-point)
-           (set-buffer current-buffer))
+         (with-current-buffer edebug-buffer
+           (goto-char edebug-buffer-outside-point))
          ;; ... nothing more.
          )
       (with-timeout-unsuspend edebug-with-timeout-suspend)
@@ -2794,8 +2772,8 @@ MSG is printed after `::::} '."
        unread-command-events edebug-outside-unread-command-events
        overlay-arrow-position edebug-outside-o-a-p
        overlay-arrow-string edebug-outside-o-a-s
-       cursor-in-echo-area edebug-outside-c-i-e-a
-       default-cursor-in-non-selected-windows edebug-outside-d-c-i-n-s-w)
+       cursor-in-echo-area edebug-outside-c-i-e-a)
+      (setq-default cursor-in-non-selected-windows edebug-outside-d-c-i-n-s-w)
       )))
 
 
@@ -2851,8 +2829,7 @@ MSG is printed after `::::} '."
   (let ((edebug-buffer-read-only buffer-read-only)
        ;; match-data must be done in the outside buffer
        (edebug-outside-match-data
-        (save-excursion  ; might be unnecessary now??
-          (set-buffer edebug-outside-buffer)  ; in case match buffer different
+        (with-current-buffer edebug-outside-buffer ; in case match buffer different
           (match-data)))
 
        ;;(edebug-number-of-recursions (1+ edebug-number-of-recursions))
@@ -3012,7 +2989,7 @@ MSG is printed after `::::} '."
   ;; Set up the overlay arrow at beginning-of-line in current buffer.
   ;; The arrow string is derived from edebug-arrow-alist and
   ;; edebug-execution-mode.
-  (let ((pos (save-excursion (beginning-of-line) (point))))
+  (let ((pos (line-beginning-position)))
     (setq overlay-arrow-string
          (cdr (assq edebug-execution-mode edebug-arrow-alist)))
     (setq overlay-arrow-position (make-marker))
@@ -3605,11 +3582,10 @@ Return the result of the last expression."
           (overlay-arrow-position edebug-outside-o-a-p)
           (overlay-arrow-string edebug-outside-o-a-s)
           (cursor-in-echo-area edebug-outside-c-i-e-a)
-          (default-cursor-in-non-selected-windows edebug-outside-d-c-i-n-s-w)
           )
+       (setq-default cursor-in-non-selected-windows edebug-outside-d-c-i-n-s-w)
        (unwind-protect
-          (save-excursion              ; of edebug-buffer
-            (set-buffer edebug-outside-buffer)
+          (with-current-buffer edebug-outside-buffer ; of edebug-buffer
             (goto-char edebug-outside-point)
             (if (marker-buffer (edebug-mark-marker))
                 (set-marker (edebug-mark-marker) edebug-outside-mark))
@@ -3642,22 +3618,24 @@ Return the result of the last expression."
          edebug-outside-o-a-p overlay-arrow-position
          edebug-outside-o-a-s overlay-arrow-string
          edebug-outside-c-i-e-a cursor-in-echo-area
-         edebug-outside-d-c-i-n-s-w default-cursor-in-non-selected-windows
-         )
+         edebug-outside-d-c-i-n-s-w (default-value
+                                       'cursor-in-non-selected-windows)
+          )
 
         ;; Restore the outside saved values; don't alter
         ;; the outside binding loci.
         (setcdr edebug-outside-pre-command-hook pre-command-hook)
         (setcdr edebug-outside-post-command-hook post-command-hook)
 
+         (setq-default cursor-in-non-selected-windows t)
         ))                             ; let
      ))
 
-(defvar cl-debug-env nil) ;; defined in cl; non-nil when lexical env used.
+(defvar cl-debug-env)  ; defined in cl; non-nil when lexical env used.
 
 (defun edebug-eval (edebug-expr)
   ;; Are there cl lexical variables active?
-  (if cl-debug-env
+  (if (bound-and-true-p cl-debug-env)
       (eval (cl-macroexpand-all edebug-expr cl-debug-env))
     (eval edebug-expr)))
 
@@ -3685,10 +3663,7 @@ Return the result of the last expression."
                                  (prin1-to-string edebug-arg)))
                      (cdr edebug-value) ", ")))
 
-;; Define here in case they are not already defined.
-(defvar print-level nil)
-(defvar print-circle nil)
-(defvar print-readably) ;; defined by lemacs
+(defvar print-readably) ; defined by lemacs
 ;; Alternatively, we could change the definition of
 ;; edebug-safe-prin1-to-string to only use these if defined.
 
@@ -3697,7 +3672,7 @@ Return the result of the last expression."
        (print-length (or edebug-print-length print-length))
        (print-level (or edebug-print-level print-level))
        (print-circle (or edebug-print-circle print-circle))
-       (print-readably nil)) ;; lemacs uses this.
+       (print-readably nil)) ; lemacs uses this.
     (condition-case nil
        (edebug-prin1-to-string value)
       (error "#Apparently circular structure#"))))
@@ -3760,6 +3735,7 @@ This prints the value into current buffer."
 
 ;;; Edebug Minor Mode
 
+;; FIXME eh?
 (defvar gud-inhibit-global-bindings
   "*Non-nil means don't do global rebindings of C-x C-a subcommands.")
 
@@ -4033,18 +4009,16 @@ May only be called from within `edebug-recursive-edit'."
 
 
 
-(defvar edebug-eval-mode-map nil
-  "Keymap for Edebug Eval mode.  Superset of Lisp Interaction mode.")
-
-(unless edebug-eval-mode-map
-  (setq edebug-eval-mode-map (make-sparse-keymap))
-  (set-keymap-parent edebug-eval-mode-map lisp-interaction-mode-map)
-
-  (define-key edebug-eval-mode-map "\C-c\C-w" 'edebug-where)
-  (define-key edebug-eval-mode-map "\C-c\C-d" 'edebug-delete-eval-item)
-  (define-key edebug-eval-mode-map "\C-c\C-u" 'edebug-update-eval-list)
-  (define-key edebug-eval-mode-map "\C-x\C-e" 'edebug-eval-last-sexp)
-  (define-key edebug-eval-mode-map "\C-j" 'edebug-eval-print-last-sexp))
+(defvar edebug-eval-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map lisp-interaction-mode-map)
+    (define-key map "\C-c\C-w" 'edebug-where)
+    (define-key map "\C-c\C-d" 'edebug-delete-eval-item)
+    (define-key map "\C-c\C-u" 'edebug-update-eval-list)
+    (define-key map "\C-x\C-e" 'edebug-eval-last-sexp)
+    (define-key map "\C-j" 'edebug-eval-print-last-sexp)
+  map)
+"Keymap for Edebug Eval mode.  Superset of Lisp Interaction mode.")
 
 (put 'edebug-eval-mode 'mode-class 'special)
 
@@ -4459,7 +4433,7 @@ With prefix argument, make it a temporary breakpoint."
   (add-hook 'cl-load-hook
            (function (lambda () (require 'cl-specs)))))
 
-;;; edebug-cl-read and cl-read are available from liberte@cs.uiuc.edu
+;; edebug-cl-read and cl-read are available from liberte@cs.uiuc.edu
 (if (featurep 'cl-read)
     (add-hook 'edebug-setup-hook
              (function (lambda () (require 'edebug-cl-read))))
@@ -4470,13 +4444,12 @@ With prefix argument, make it a temporary breakpoint."
 \f
 ;;; Finalize Loading
 
-;;; Finally, hook edebug into the rest of Emacs.
-;;; There are probably some other things that could go here.
+;; Finally, hook edebug into the rest of Emacs.
+;; There are probably some other things that could go here.
 
 ;; Install edebug read and eval functions.
 (edebug-install-read-eval-functions)
 
 (provide 'edebug)
 
-;; arch-tag: 19c8d05c-4554-426e-ac72-e0fa1fcb0808
 ;;; edebug.el ends here