;;; 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 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
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
(defcustom edebug-setup-hook nil
- "*Functions to call before edebug is used.
+ "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
+once and then reset `edebug-setup-hook' 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)
;;;###autoload
(defcustom edebug-all-defs nil
- "*If non-nil, evaluating defining forms instruments for Edebug.
+ "If non-nil, evaluating defining forms instruments for Edebug.
This applies to `eval-defun', `eval-region', `eval-buffer', and
`eval-current-buffer'. `eval-region' is also called by
`eval-last-sexp', and `eval-print-last-sexp'.
;;;###autoload
(defcustom edebug-all-forms nil
- "*Non-nil evaluation of all forms will instrument for Edebug.
+ "Non-nil means evaluation of all forms will instrument for Edebug.
This doesn't apply to loading or evaluations in the minibuffer.
Use the command `edebug-all-forms' to toggle the value of this option."
:type 'boolean
:group 'edebug)
(defcustom edebug-eval-macro-args nil
- "*Non-nil means all macro call arguments may be evaluated.
+ "Non-nil means all macro call arguments may be evaluated.
If this variable is nil, the default, Edebug will *not* wrap
macro call arguments as if they will be evaluated.
-For each macro, a `edebug-form-spec' overrides this option.
+For each macro, an `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'."
+and some not, use `def-edebug-spec' to specify an `edebug-form-spec'."
:type 'boolean
:group 'edebug)
(defcustom edebug-save-windows t
- "*If non-nil, Edebug saves and restores the window configuration.
+ "If non-nil, Edebug saves and restores the window configuration.
That takes some time, so if your program does not care what happens to
the window configurations, it is better to set this variable to nil.
:group 'edebug)
(defcustom edebug-save-displayed-buffer-points nil
- "*If non-nil, save and restore point in all displayed buffers.
+ "If non-nil, save and restore point in all displayed buffers.
Saving and restoring point in other buffers is necessary if you are
-debugging code that changes the point of a buffer which is displayed
+debugging code that changes the point of a buffer that is displayed
in a non-selected window. If Edebug or the user then selects the
window, the buffer's point will be changed to the window's point.
Saving and restoring point in all buffers is expensive, since it
-requires selecting each window twice, so enable this only if you need
-it."
+requires selecting each window twice, so enable this only if you
+need it."
:type 'boolean
:group 'edebug)
(defcustom edebug-initial-mode 'step
- "*Initial execution mode for Edebug, if non-nil.
+ "Initial execution mode for Edebug, if non-nil.
If this variable is non-nil, it specifies the initial execution mode
for Edebug when it is first activated. Possible values are step, next,
go, Go-nonstop, trace, Trace-fast, continue, and Continue-fast."
:group 'edebug)
(defcustom edebug-trace nil
- "*Non-nil means display a trace of function entry and exit.
+ "Non-nil means display a trace of function entry and exit.
Tracing output is displayed in a buffer named `*edebug-trace*', one
function entry or exit per line, indented by the recursion level.
:group 'edebug)
(defcustom edebug-test-coverage nil
- "*If non-nil, Edebug tests coverage of all expressions debugged.
-This is done by comparing the result of each expression
-with the previous result. Coverage is considered OK if two different
+ "If non-nil, Edebug tests coverage of all expressions debugged.
+This is done by comparing the result of each expression with the
+previous result. Coverage is considered OK if two different
results are found.
Use `edebug-display-freq-count' to display the frequency count and
:group 'edebug)
(defcustom edebug-continue-kbd-macro nil
- "*If non-nil, continue defining or executing any keyboard macro.
+ "If non-nil, continue defining or executing any keyboard macro.
Use this with caution since it is not debugged."
:type 'boolean
:group 'edebug)
(defcustom edebug-print-length 50
- "*Default value of `print-length' for printing results in Edebug."
+ "If non-nil, default value of `print-length' for printing results in Edebug."
:type 'integer
:group 'edebug)
(defcustom edebug-print-level 50
- "*Default value of `print-level' for printing results in Edebug."
+ "If non-nil, default value of `print-level' for printing results in Edebug."
:type 'integer
:group 'edebug)
(defcustom edebug-print-circle t
- "*Default value of `print-circle' for printing results in Edebug."
+ "If non-nil, default value of `print-circle' for printing results in Edebug."
:type 'boolean
:group 'edebug)
(defcustom edebug-unwrap-results nil
- "*Non-nil if Edebug should unwrap results of expressions.
+ "Non-nil if Edebug should unwrap results of expressions.
This is useful when debugging macros where the results of expressions
are instrumented expressions. But don't do this when results might be
circular or an infinite loop will result."
:group 'edebug)
(defcustom edebug-on-error t
- "*Value bound to `debug-on-error' while Edebug is active.
+ "Value bound to `debug-on-error' while Edebug is active.
If `debug-on-error' is non-nil, that value is still used.
:group 'edebug)
(defcustom edebug-on-quit t
- "*Value bound to `debug-on-quit' while Edebug is active."
+ "Value bound to `debug-on-quit' while Edebug is active."
:type 'boolean
:group 'edebug)
(defcustom edebug-global-break-condition nil
- "*If non-nil, an expression to test for at every stop point.
+ "If non-nil, an expression to test for at every stop point.
If the result is non-nil, then break. Errors are ignored."
:type 'sexp
:group 'edebug)
(defcustom edebug-sit-for-seconds 1
- "*Number of seconds to pause when execution mode is `trace'."
+ "Number of seconds to pause when execution mode is `trace' or `continue'."
:type 'number
:group 'edebug)
(defun edebug-gensym (&optional prefix)
"Generate a fresh uninterned symbol.
-There is an optional argument, PREFIX. PREFIX is the
-string that begins the new name. Most people take just the default,
+There is an optional argument, PREFIX. PREFIX is the string
+that begins the new name. Most people take just the default,
except when debugging needs suggest otherwise."
(if (null prefix)
(setq prefix "G"))
(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
a string (takes text from string, starting at the beginning)
t (read text line using minibuffer and use it).
-This version, from Edebug, maybe instruments the expression. But the
+This version, from Edebug, maybe instruments the expression. But the
STREAM must be the current buffer to do so. Whether it instruments is
also dependent on the values of `edebug-all-defs' and
`edebug-all-forms'."
the prefix argument. Code is then instrumented when this function is
invoked without a prefix argument
-If acting on a `defun' for FUNCTION, and the function was
-instrumented, `Edebug: FUNCTION' is printed in the minibuffer. If not
-instrumented, just FUNCTION is printed.
+If acting on a `defun' for FUNCTION, and the function was instrumented,
+`Edebug: FUNCTION' is printed in the minibuffer. If not instrumented,
+just FUNCTION is printed.
If not acting on a `defun', the result of evaluation is displayed in
the minibuffer."
before evaluating it. It displays the value in the echo area
using `eval-expression' (which see).
-If you do this on a function definition
-such as a defun or defmacro, it defines the function and instruments
-its definition for Edebug, so it will do Edebug stepping when called
-later. It displays `Edebug: FUNCTION' in the echo area to indicate
-that FUNCTION is now instrumented for Edebug.
+If you do this on a function definition such as a defun or defmacro,
+it defines the function and instruments its definition for Edebug,
+so it will do Edebug stepping when called later. It displays
+`Edebug: FUNCTION' in the echo area to indicate that FUNCTION is now
+instrumented for Edebug.
If the current defun is actually a call to `defvar' or `defcustom',
evaluating it this way resets the variable using its initial value
(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.
(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)
(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)
sexp))
(defun edebug-unwrap* (sexp)
- "Return the sexp recursively unwrapped."
+ "Return the SEXP recursively unwrapped."
(let ((new-sexp (edebug-unwrap sexp)))
(while (not (eq sexp new-sexp))
(setq sexp new-sexp
(cond
((symbolp head)
(cond
- ((null head) nil) ; () is legal.
+ ((null head) nil) ; () is valid.
((eq head 'interactive-p)
;; Special case: replace (interactive-p) with variable
(setq edebug-def-interactive 'check-it)
[&optional stringp]
[&optional ("interactive" interactive)]
def-body))
+;; FIXME? Isn't this missing the doc-string? Cf defun.
(def-edebug-spec defmacro
(&define name lambda-list [&optional ("declare" &rest sexp)] def-body))
(def-edebug-spec apply (function-form &rest form))
(def-edebug-spec funcall (function-form &rest form))
+;; FIXME? The manual has a gate here.
(def-edebug-spec let
((&rest &or (symbolp &optional form) symbolp)
body))
;; doesn't handle (a . ,b). The straightforward fix:
;; (backquote-form . [&or nil backquote-form])
;; uses up too much stack space.
- ;; Note that `(foo . ,@bar) is not legal, so we don't need to handle it.
+ ;; Note that `(foo . ,@bar) is not valid, so we don't need to handle it.
(backquote-form [&rest [¬ ","] backquote-form]
. [&or nil backquote-form])
;; If you use dotted forms in backquotes, replace the previous line
(def-edebug-spec with-custom-print body)
-(def-edebug-spec sregexq (&rest sexp))
-(def-edebug-spec rx (&rest sexp))
;;; The debugger itself
This is the Edebug replacement for the standard `signal'. It should
only be active while Edebug is. It checks `debug-on-error' to see
whether it should call the debugger. When execution is resumed, the
-error is signaled again."
+error is signaled again.
+\n(fn SIGNAL-NAME DATA)"
(if (and (listp debug-on-error) (memq edebug-signal-name debug-on-error))
(edebug 'error (cons edebug-signal-name edebug-signal-data)))
;; If we reach here without another non-local exit, then send signal again.
(defun edebug-restore-status (var status)
"Reset VAR based on STATUS.
-STATUS should be a list you got from `edebug-var-status'."
+STATUS should be a list returned by `edebug-var-status'."
(let ((locus (car status))
(value (cdr status)))
(cond ((bufferp locus)
(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)))
;; 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)
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)
)))
(defvar edebug-outside-standard-output)
(defvar edebug-outside-standard-input)
(defvar edebug-outside-current-prefix-arg)
-(defvar edebug-outside-last-command-char)
(defvar edebug-outside-last-command)
(defvar edebug-outside-this-command)
-(defvar edebug-outside-last-input-char)
;; Note: here we have defvars for variables that are
;; built-in in certain versions.
;; Each defvar makes a difference
;; in versions where the variable is *not* built-in.
-;; Emacs 18
+;; Emacs 18 FIXME
(defvar edebug-outside-unread-command-char)
;; Emacs 19.
;; (maybe works with byte-compile-version 2.22 at least)
(defvar edebug-unread-command-char-warning)
(defvar edebug-unread-command-event-warning)
-(eval-when-compile
+(eval-when-compile ; FIXME
(setq edebug-unread-command-char-warning
(get 'unread-command-char 'byte-obsolete-variable))
(put 'unread-command-char 'byte-obsolete-variable nil))
(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))
(edebug-outside-standard-input standard-input)
(edebug-outside-defining-kbd-macro defining-kbd-macro)
- (edebug-outside-last-command-char last-command-char)
(edebug-outside-last-command last-command)
(edebug-outside-this-command this-command)
- (edebug-outside-last-input-char last-input-char)
- (edebug-outside-unread-command-char unread-command-char)
+ (edebug-outside-unread-command-char unread-command-char) ; FIXME
(edebug-outside-current-prefix-arg current-prefix-arg)
(edebug-outside-last-input-event last-input-event)
(let (
;; Declare global values local but using the same global value.
;; We could set these to the values for previous edebug call.
- (last-command-char last-command-char)
(last-command last-command)
(this-command this-command)
- (last-input-char last-input-char)
;; Assume no edebug command sets unread-command-char.
(unread-command-char -1)
;; Reset global vars to outside values, in case they have been changed.
(setq
- last-command-char edebug-outside-last-command-char
last-command-event edebug-outside-last-command-event
last-command edebug-outside-last-command
this-command edebug-outside-this-command
unread-command-char edebug-outside-unread-command-char
current-prefix-arg edebug-outside-current-prefix-arg
- last-input-char edebug-outside-last-input-char
last-input-event edebug-outside-last-input-event
last-event-frame edebug-outside-last-event-frame
last-nonmenu-event edebug-outside-last-nonmenu-event
;; 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))
(goto-char edebug-point))
(defun edebug-view-outside ()
- "Change to the outside window configuration."
+ "Change to the outside window configuration.
+Use `edebug-where' to return."
(interactive)
(if (not edebug-active)
(error "Edebug is not active"))
(defun edebug-bounce-point (arg)
"Bounce the point in the outside current buffer.
-If prefix arg is supplied, sit for that many seconds before returning.
-The default is one second."
+If prefix argument ARG is supplied, sit for that many seconds
+before returning. The default is one second."
(interactive "p")
(if (not edebug-active)
(error "Edebug is not active"))
(defun edebug-set-global-break-condition (expression)
+ "Set `edebug-global-break-condition' to EXPRESSION."
(interactive
(list
(let ((initial (and edebug-global-break-condition
(edebug-set-mode 'go "Go..." "Edebug will go until break."))
(defun edebug-Go-nonstop-mode ()
- "Go, evaluating without debugging."
+ "Go, evaluating without debugging.
+You can use `edebug-stop', or any editing command, to stop."
(interactive)
(edebug-set-mode 'Go-nonstop "Go-Nonstop..."
"Edebug will not stop at breaks."))
(defun edebug-trace-mode ()
- "Begin trace mode."
+ "Begin trace mode.
+Pauses for `edebug-sit-for-seconds' at each stop point."
(interactive)
(edebug-set-mode 'trace "Tracing..." "Edebug will trace with pause."))
(defun edebug-Trace-fast-mode ()
- "Trace with no wait at each step."
+ "Trace with no wait at each step.
+Updates the display at each stop point, but does not pause."
(interactive)
(edebug-set-mode 'Trace-fast
"Trace fast..." "Edebug will trace without pause."))
(defun edebug-continue-mode ()
- "Begin continue mode."
+ "Begin continue mode.
+Pauses for `edebug-sit-for-seconds' at each break point."
(interactive)
(edebug-set-mode 'continue "Continue..."
"Edebug will pause at breakpoints."))
(defun edebug-Continue-fast-mode ()
- "Trace with no wait at each step."
+ "Trace with no wait at each step.
+Updates the display at each break point, but does not pause."
(interactive)
(edebug-set-mode 'Continue-fast "Continue fast..."
"Edebug will stop and go at breakpoints."))
(defun edebug-forward-sexp (arg)
"Proceed from the current point to the end of the ARGth sexp ahead.
-If there are not ARG sexps ahead, then do edebug-step-out."
+If there are not ARG sexps ahead, then do `edebug-step-out'."
(interactive "p")
(condition-case nil
(let ((parse-sexp-ignore-comments t))
(defun edebug-top-level-nonstop ()
"Set mode to Go-nonstop, and exit to top-level.
-This is useful for exiting even if unwind-protect code may be executed."
+This is useful for exiting even if `unwind-protect' code may be executed."
(interactive)
(setq edebug-execution-mode 'Go-nonstop)
(top-level))
(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)
(last-command-event edebug-outside-last-command-event)
(last-command edebug-outside-last-command)
(this-command edebug-outside-this-command)
(unread-command-char edebug-outside-unread-command-char)
(unread-command-events edebug-outside-unread-command-events)
(current-prefix-arg edebug-outside-current-prefix-arg)
- (last-input-char edebug-outside-last-input-char)
(last-input-event edebug-outside-last-input-event)
(last-event-frame edebug-outside-last-event-frame)
(last-nonmenu-event edebug-outside-last-nonmenu-event)
(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))
;; Save values that may have been changed.
(setq
- edebug-outside-last-command-char last-command-char
edebug-outside-last-command-event last-command-event
edebug-outside-last-command last-command
edebug-outside-this-command this-command
edebug-outside-unread-command-char unread-command-char
edebug-outside-unread-command-events unread-command-events
edebug-outside-current-prefix-arg current-prefix-arg
- edebug-outside-last-input-char last-input-char
edebug-outside-last-input-event last-input-event
edebug-outside-last-event-frame last-event-frame
edebug-outside-last-nonmenu-event last-nonmenu-event
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)))
(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.
(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#"))))
;;; Edebug Minor Mode
+;; FIXME eh?
(defvar gud-inhibit-global-bindings
"*Non-nil means don't do global rebindings of C-x C-a subcommands.")
(defun edebug-help ()
+ "Describe `edebug-mode'."
(interactive)
(describe-function 'edebug-mode))
;; A list of expressions and their evaluations is displayed in *edebug*.
(defun edebug-eval-result-list ()
- "Return a list of evaluations of edebug-eval-list"
+ "Return a list of evaluations of `edebug-eval-list'."
;; Assumes in outside environment.
;; Don't do any edebug things now.
(let ((edebug-execution-mode 'Go-nonstop)
;; with calls in user functions, e.g. (edebug-eval-display)
(defun edebug-eval-display (edebug-eval-result-list)
- "Display expressions and evaluations in EVAL-LIST.
+ "Display expressions and evaluations in EDEBUG-EVAL-RESULT-LIST.
It modifies the context by popping up the eval display."
(if edebug-eval-result-list
(progn
(defun edebug-eval-redisplay ()
"Redisplay eval list in outside environment.
-May only be called from within edebug-recursive-edit."
+May only be called from within `edebug-recursive-edit'."
(edebug-create-eval-buffer)
(edebug-outside-excursion
(edebug-eval-display-list (edebug-eval-result-list))
))
(defun edebug-visit-eval-list ()
+ "Switch to the evaluation list buffer \"*edebug*\"."
(interactive)
(edebug-eval-redisplay)
(edebug-pop-to-buffer edebug-eval-buffer))
-(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)
;; edebug is not dependent on this, yet.
(defun edebug (&optional edebug-arg-mode &rest debugger-args)
- "Replacement for debug.
-If we are running an edebugged function,
-show where we last were. Otherwise call debug normally."
+ "Replacement for `debug'.
+If we are running an edebugged function, show where we last were.
+Otherwise call `debug' normally."
;; (message "entered: %s depth: %s edebug-recursion-depth: %s"
;; edebug-entered (recursion-depth) edebug-recursion-depth) (sit-for 1)
(if (and edebug-entered ; anything active?
(with-output-to-temp-buffer (buffer-name edebug-backtrace-buffer)
(setq edebug-backtrace-buffer standard-output)
(let ((print-escape-newlines t)
- (print-length 50)
+ (print-length 50) ; FIXME cf edebug-safe-prin1-to-string
last-ok-point)
(backtrace)
(defun edebug-trace (fmt &rest args)
- "Convenience call to edebug-trace-display using edebug-trace-buffer"
+ "Convenience call to `edebug-trace-display' using `edebug-trace-buffer'."
(apply 'edebug-trace-display edebug-trace-buffer fmt args))
\f
;;; Frequency count and coverage
+;; FIXME should this use overlays instead?
(defun edebug-display-freq-count ()
"Display the frequency count data for each line of the current definition.
-The frequency counts are inserted as comment lines after
-each line, and you can undo all insertions with one `undo' command.
+The frequency counts are inserted as comment lines after each line,
+and you can undo all insertions with one `undo' command.
The counts are inserted starting under the `(' before an expression
or the `)' after an expression, or on the last char of a symbol.
(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))))
\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