comparison lisp/emacs-lisp/edebug.el @ 103885:adbe0e36df45

(edebug-setup-hook, edebug-all-forms) (edebug-eval-macro-args, edebug-save-displayed-buffer-points) (edebug-print-length, edebug-print-level, edebug-print-circle) (edebug-sit-for-seconds, edebug-view-outside) (edebug-bounce-point, edebug-set-global-break-condition) (edebug-Go-nonstop-mode, edebug-trace-mode) (edebug-Trace-fast-mode, edebug-continue-mode) (edebug-Continue-fast-mode, edebug-forward-sexp, edebug-help) (edebug-visit-eval-list): Doc fixes.
author Glenn Morris <rgm@gnu.org>
date Tue, 14 Jul 2009 08:01:50 +0000
parents 0c2777fdd83f
children f0176ca49d34
comparison
equal deleted inserted replaced
103884:dbafc1b9107d 103885:adbe0e36df45
65 65
66 66
67 (defcustom edebug-setup-hook nil 67 (defcustom edebug-setup-hook nil
68 "Functions to call before edebug is used. 68 "Functions to call before edebug is used.
69 Each time it is set to a new value, Edebug will call those functions 69 Each time it is set to a new value, Edebug will call those functions
70 once and then `edebug-setup-hook' is reset to nil. You could use this 70 once and then reset `edebug-setup-hook' to nil. You could use this
71 to load up Edebug specifications associated with a package you are 71 to load up Edebug specifications associated with a package you are
72 using but only when you also use Edebug." 72 using, but only when you also use Edebug."
73 :type 'hook 73 :type 'hook
74 :group 'edebug) 74 :group 'edebug)
75 75
76 ;; edebug-all-defs and edebug-all-forms need to be autoloaded 76 ;; edebug-all-defs and edebug-all-forms need to be autoloaded
77 ;; because the byte compiler binds them; as a result, if edebug 77 ;; because the byte compiler binds them; as a result, if edebug
95 ;; because the byte compiler binds them; as a result, if edebug 95 ;; because the byte compiler binds them; as a result, if edebug
96 ;; is first loaded for a require in a compilation, they will be left unbound. 96 ;; is first loaded for a require in a compilation, they will be left unbound.
97 97
98 ;;;###autoload 98 ;;;###autoload
99 (defcustom edebug-all-forms nil 99 (defcustom edebug-all-forms nil
100 "Non-nil evaluation of all forms will instrument for Edebug. 100 "Non-nil means evaluation of all forms will instrument for Edebug.
101 This doesn't apply to loading or evaluations in the minibuffer. 101 This doesn't apply to loading or evaluations in the minibuffer.
102 Use the command `edebug-all-forms' to toggle the value of this option." 102 Use the command `edebug-all-forms' to toggle the value of this option."
103 :type 'boolean 103 :type 'boolean
104 :group 'edebug) 104 :group 'edebug)
105 105
106 (defcustom edebug-eval-macro-args nil 106 (defcustom edebug-eval-macro-args nil
107 "Non-nil means all macro call arguments may be evaluated. 107 "Non-nil means all macro call arguments may be evaluated.
108 If this variable is nil, the default, Edebug will *not* wrap 108 If this variable is nil, the default, Edebug will *not* wrap
109 macro call arguments as if they will be evaluated. 109 macro call arguments as if they will be evaluated.
110 For each macro, a `edebug-form-spec' overrides this option. 110 For each macro, an `edebug-form-spec' overrides this option.
111 So to specify exceptions for macros that have some arguments evaluated 111 So to specify exceptions for macros that have some arguments evaluated
112 and some not, you should specify an `edebug-form-spec'." 112 and some not, use `def-edebug-spec' to specify an `edebug-form-spec'."
113 :type 'boolean 113 :type 'boolean
114 :group 'edebug) 114 :group 'edebug)
115 115
116 (defcustom edebug-save-windows t 116 (defcustom edebug-save-windows t
117 "If non-nil, Edebug saves and restores the window configuration. 117 "If non-nil, Edebug saves and restores the window configuration.
127 127
128 (defcustom edebug-save-displayed-buffer-points nil 128 (defcustom edebug-save-displayed-buffer-points nil
129 "If non-nil, save and restore point in all displayed buffers. 129 "If non-nil, save and restore point in all displayed buffers.
130 130
131 Saving and restoring point in other buffers is necessary if you are 131 Saving and restoring point in other buffers is necessary if you are
132 debugging code that changes the point of a buffer which is displayed 132 debugging code that changes the point of a buffer that is displayed
133 in a non-selected window. If Edebug or the user then selects the 133 in a non-selected window. If Edebug or the user then selects the
134 window, the buffer's point will be changed to the window's point. 134 window, the buffer's point will be changed to the window's point.
135 135
136 Saving and restoring point in all buffers is expensive, since it 136 Saving and restoring point in all buffers is expensive, since it
137 requires selecting each window twice, so enable this only if you need 137 requires selecting each window twice, so enable this only if you
138 it." 138 need it."
139 :type 'boolean 139 :type 'boolean
140 :group 'edebug) 140 :group 'edebug)
141 141
142 (defcustom edebug-initial-mode 'step 142 (defcustom edebug-initial-mode 'step
143 "Initial execution mode for Edebug, if non-nil. 143 "Initial execution mode for Edebug, if non-nil.
177 :type 'boolean 177 :type 'boolean
178 :group 'edebug) 178 :group 'edebug)
179 179
180 180
181 (defcustom edebug-print-length 50 181 (defcustom edebug-print-length 50
182 "Default value of `print-length' for printing results in Edebug." 182 "If non-nil, default value of `print-length' for printing results in Edebug."
183 :type 'integer 183 :type 'integer
184 :group 'edebug) 184 :group 'edebug)
185 (defcustom edebug-print-level 50 185 (defcustom edebug-print-level 50
186 "Default value of `print-level' for printing results in Edebug." 186 "If non-nil, default value of `print-level' for printing results in Edebug."
187 :type 'integer 187 :type 'integer
188 :group 'edebug) 188 :group 'edebug)
189 (defcustom edebug-print-circle t 189 (defcustom edebug-print-circle t
190 "Default value of `print-circle' for printing results in Edebug." 190 "If non-nil, default value of `print-circle' for printing results in Edebug."
191 :type 'boolean 191 :type 'boolean
192 :group 'edebug) 192 :group 'edebug)
193 193
194 (defcustom edebug-unwrap-results nil 194 (defcustom edebug-unwrap-results nil
195 "Non-nil if Edebug should unwrap results of expressions. 195 "Non-nil if Edebug should unwrap results of expressions.
226 If the result is non-nil, then break. Errors are ignored." 226 If the result is non-nil, then break. Errors are ignored."
227 :type 'sexp 227 :type 'sexp
228 :group 'edebug) 228 :group 'edebug)
229 229
230 (defcustom edebug-sit-for-seconds 1 230 (defcustom edebug-sit-for-seconds 1
231 "Number of seconds to pause when execution mode is `trace'." 231 "Number of seconds to pause when execution mode is `trace' or `continue'."
232 :type 'number 232 :type 'number
233 :group 'edebug) 233 :group 'edebug)
234 234
235 ;;; Form spec utilities. 235 ;;; Form spec utilities.
236 236
2001 (def-edebug-spec defun 2001 (def-edebug-spec defun
2002 (&define name lambda-list 2002 (&define name lambda-list
2003 [&optional stringp] 2003 [&optional stringp]
2004 [&optional ("interactive" interactive)] 2004 [&optional ("interactive" interactive)]
2005 def-body)) 2005 def-body))
2006 ;; FIXME? Isn't this missing the doc-string? Cf defun.
2006 (def-edebug-spec defmacro 2007 (def-edebug-spec defmacro
2007 (&define name lambda-list [&optional ("declare" &rest sexp)] def-body)) 2008 (&define name lambda-list [&optional ("declare" &rest sexp)] def-body))
2008 2009
2009 (def-edebug-spec arglist lambda-list) ;; deprecated - use lambda-list. 2010 (def-edebug-spec arglist lambda-list) ;; deprecated - use lambda-list.
2010 2011
2044 (def-edebug-spec mapconcat (function-form form form)) 2045 (def-edebug-spec mapconcat (function-form form form))
2045 (def-edebug-spec mapatoms (function-form &optional form)) 2046 (def-edebug-spec mapatoms (function-form &optional form))
2046 (def-edebug-spec apply (function-form &rest form)) 2047 (def-edebug-spec apply (function-form &rest form))
2047 (def-edebug-spec funcall (function-form &rest form)) 2048 (def-edebug-spec funcall (function-form &rest form))
2048 2049
2050 ;; FIXME? The manual has a gate here.
2049 (def-edebug-spec let 2051 (def-edebug-spec let
2050 ((&rest &or (symbolp &optional form) symbolp) 2052 ((&rest &or (symbolp &optional form) symbolp)
2051 body)) 2053 body))
2052 2054
2053 (def-edebug-spec let* let) 2055 (def-edebug-spec let* let)
2820 ;; Note: here we have defvars for variables that are 2822 ;; Note: here we have defvars for variables that are
2821 ;; built-in in certain versions. 2823 ;; built-in in certain versions.
2822 ;; Each defvar makes a difference 2824 ;; Each defvar makes a difference
2823 ;; in versions where the variable is *not* built-in. 2825 ;; in versions where the variable is *not* built-in.
2824 2826
2825 ;; Emacs 18 2827 ;; Emacs 18 FIXME
2826 (defvar edebug-outside-unread-command-char) 2828 (defvar edebug-outside-unread-command-char)
2827 2829
2828 ;; Emacs 19. 2830 ;; Emacs 19.
2829 (defvar edebug-outside-last-command-event) 2831 (defvar edebug-outside-last-command-event)
2830 (defvar edebug-outside-unread-command-events) 2832 (defvar edebug-outside-unread-command-events)
2835 2837
2836 ;; Disable byte compiler warnings about unread-command-char and -event 2838 ;; Disable byte compiler warnings about unread-command-char and -event
2837 ;; (maybe works with byte-compile-version 2.22 at least) 2839 ;; (maybe works with byte-compile-version 2.22 at least)
2838 (defvar edebug-unread-command-char-warning) 2840 (defvar edebug-unread-command-char-warning)
2839 (defvar edebug-unread-command-event-warning) 2841 (defvar edebug-unread-command-event-warning)
2840 (eval-when-compile 2842 (eval-when-compile ; FIXME
2841 (setq edebug-unread-command-char-warning 2843 (setq edebug-unread-command-char-warning
2842 (get 'unread-command-char 'byte-obsolete-variable)) 2844 (get 'unread-command-char 'byte-obsolete-variable))
2843 (put 'unread-command-char 'byte-obsolete-variable nil)) 2845 (put 'unread-command-char 'byte-obsolete-variable nil))
2844 2846
2845 (defun edebug-recursive-edit () 2847 (defun edebug-recursive-edit ()
2869 (edebug-outside-defining-kbd-macro defining-kbd-macro) 2871 (edebug-outside-defining-kbd-macro defining-kbd-macro)
2870 2872
2871 (edebug-outside-last-command last-command) 2873 (edebug-outside-last-command last-command)
2872 (edebug-outside-this-command this-command) 2874 (edebug-outside-this-command this-command)
2873 2875
2874 (edebug-outside-unread-command-char unread-command-char) 2876 (edebug-outside-unread-command-char unread-command-char) ; FIXME
2875 (edebug-outside-current-prefix-arg current-prefix-arg) 2877 (edebug-outside-current-prefix-arg current-prefix-arg)
2876 2878
2877 (edebug-outside-last-input-event last-input-event) 2879 (edebug-outside-last-input-event last-input-event)
2878 (edebug-outside-last-command-event last-command-event) 2880 (edebug-outside-last-command-event last-command-event)
2879 (edebug-outside-last-event-frame last-event-frame) 2881 (edebug-outside-last-event-frame last-event-frame)
3089 ;; (edebug-set-windows edebug-inside-windows)) 3091 ;; (edebug-set-windows edebug-inside-windows))
3090 (edebug-pop-to-buffer edebug-buffer) 3092 (edebug-pop-to-buffer edebug-buffer)
3091 (goto-char edebug-point)) 3093 (goto-char edebug-point))
3092 3094
3093 (defun edebug-view-outside () 3095 (defun edebug-view-outside ()
3094 "Change to the outside window configuration." 3096 "Change to the outside window configuration.
3097 Use `edebug-where' to return."
3095 (interactive) 3098 (interactive)
3096 (if (not edebug-active) 3099 (if (not edebug-active)
3097 (error "Edebug is not active")) 3100 (error "Edebug is not active"))
3098 (setq edebug-inside-windows 3101 (setq edebug-inside-windows
3099 (edebug-current-windows edebug-save-windows)) 3102 (edebug-current-windows edebug-save-windows))
3103 (substitute-command-keys "\\<global-map>\\[edebug-where]"))) 3106 (substitute-command-keys "\\<global-map>\\[edebug-where]")))
3104 3107
3105 3108
3106 (defun edebug-bounce-point (arg) 3109 (defun edebug-bounce-point (arg)
3107 "Bounce the point in the outside current buffer. 3110 "Bounce the point in the outside current buffer.
3108 If prefix arg is supplied, sit for that many seconds before returning. 3111 If prefix argument ARG is supplied, sit for that many seconds
3109 The default is one second." 3112 before returning. The default is one second."
3110 (interactive "p") 3113 (interactive "p")
3111 (if (not edebug-active) 3114 (if (not edebug-active)
3112 (error "Edebug is not active")) 3115 (error "Edebug is not active"))
3113 (save-excursion 3116 (save-excursion
3114 ;; If the buffer's currently displayed, avoid set-window-configuration. 3117 ;; If the buffer's currently displayed, avoid set-window-configuration.
3265 (interactive) 3268 (interactive)
3266 (edebug-modify-breakpoint nil)) 3269 (edebug-modify-breakpoint nil))
3267 3270
3268 3271
3269 (defun edebug-set-global-break-condition (expression) 3272 (defun edebug-set-global-break-condition (expression)
3273 "Set `edebug-global-break-condition' to EXPRESSION."
3270 (interactive 3274 (interactive
3271 (list 3275 (list
3272 (let ((initial (and edebug-global-break-condition 3276 (let ((initial (and edebug-global-break-condition
3273 (format "%s" edebug-global-break-condition)))) 3277 (format "%s" edebug-global-break-condition))))
3274 (read-from-minibuffer 3278 (read-from-minibuffer
3314 (if arg 3318 (if arg
3315 (edebug-set-breakpoint t)) 3319 (edebug-set-breakpoint t))
3316 (edebug-set-mode 'go "Go..." "Edebug will go until break.")) 3320 (edebug-set-mode 'go "Go..." "Edebug will go until break."))
3317 3321
3318 (defun edebug-Go-nonstop-mode () 3322 (defun edebug-Go-nonstop-mode ()
3319 "Go, evaluating without debugging." 3323 "Go, evaluating without debugging.
3324 You can use `edebug-stop', or any editing command, to stop."
3320 (interactive) 3325 (interactive)
3321 (edebug-set-mode 'Go-nonstop "Go-Nonstop..." 3326 (edebug-set-mode 'Go-nonstop "Go-Nonstop..."
3322 "Edebug will not stop at breaks.")) 3327 "Edebug will not stop at breaks."))
3323 3328
3324 3329
3325 (defun edebug-trace-mode () 3330 (defun edebug-trace-mode ()
3326 "Begin trace mode." 3331 "Begin trace mode.
3332 Pauses for `edebug-sit-for-seconds' at each stop point."
3327 (interactive) 3333 (interactive)
3328 (edebug-set-mode 'trace "Tracing..." "Edebug will trace with pause.")) 3334 (edebug-set-mode 'trace "Tracing..." "Edebug will trace with pause."))
3329 3335
3330 (defun edebug-Trace-fast-mode () 3336 (defun edebug-Trace-fast-mode ()
3331 "Trace with no wait at each step." 3337 "Trace with no wait at each step.
3338 Updates the display at each stop point, but does not pause."
3332 (interactive) 3339 (interactive)
3333 (edebug-set-mode 'Trace-fast 3340 (edebug-set-mode 'Trace-fast
3334 "Trace fast..." "Edebug will trace without pause.")) 3341 "Trace fast..." "Edebug will trace without pause."))
3335 3342
3336 (defun edebug-continue-mode () 3343 (defun edebug-continue-mode ()
3337 "Begin continue mode." 3344 "Begin continue mode.
3345 Pauses for `edebug-sit-for-seconds' at each break point."
3338 (interactive) 3346 (interactive)
3339 (edebug-set-mode 'continue "Continue..." 3347 (edebug-set-mode 'continue "Continue..."
3340 "Edebug will pause at breakpoints.")) 3348 "Edebug will pause at breakpoints."))
3341 3349
3342 (defun edebug-Continue-fast-mode () 3350 (defun edebug-Continue-fast-mode ()
3343 "Trace with no wait at each step." 3351 "Trace with no wait at each step.
3352 Updates the display at each break point, but does not pause."
3344 (interactive) 3353 (interactive)
3345 (edebug-set-mode 'Continue-fast "Continue fast..." 3354 (edebug-set-mode 'Continue-fast "Continue fast..."
3346 "Edebug will stop and go at breakpoints.")) 3355 "Edebug will stop and go at breakpoints."))
3347 3356
3348 ;; ------------------------------------------------------------ 3357 ;; ------------------------------------------------------------
3370 "Edebug will stop after exiting the next expression.")) 3379 "Edebug will stop after exiting the next expression."))
3371 3380
3372 3381
3373 (defun edebug-forward-sexp (arg) 3382 (defun edebug-forward-sexp (arg)
3374 "Proceed from the current point to the end of the ARGth sexp ahead. 3383 "Proceed from the current point to the end of the ARGth sexp ahead.
3375 If there are not ARG sexps ahead, then do edebug-step-out." 3384 If there are not ARG sexps ahead, then do `edebug-step-out'."
3376 (interactive "p") 3385 (interactive "p")
3377 (condition-case nil 3386 (condition-case nil
3378 (let ((parse-sexp-ignore-comments t)) 3387 (let ((parse-sexp-ignore-comments t))
3379 ;; Call forward-sexp repeatedly until done or failure. 3388 ;; Call forward-sexp repeatedly until done or failure.
3380 (forward-sexp arg) 3389 (forward-sexp arg)
3868 (global-unset-key global-edebug-prefix) 3877 (global-unset-key global-edebug-prefix)
3869 (global-set-key global-edebug-prefix global-edebug-map) 3878 (global-set-key global-edebug-prefix global-edebug-map)
3870 3879
3871 3880
3872 (defun edebug-help () 3881 (defun edebug-help ()
3882 "Describe `edebug-mode'."
3873 (interactive) 3883 (interactive)
3874 (describe-function 'edebug-mode)) 3884 (describe-function 'edebug-mode))
3875 3885
3876 (defun edebug-mode () 3886 (defun edebug-mode ()
3877 "Mode for Emacs Lisp buffers while in Edebug. 3887 "Mode for Emacs Lisp buffers while in Edebug.
3974 (edebug-outside-excursion 3984 (edebug-outside-excursion
3975 (edebug-eval-display-list (edebug-eval-result-list)) 3985 (edebug-eval-display-list (edebug-eval-result-list))
3976 )) 3986 ))
3977 3987
3978 (defun edebug-visit-eval-list () 3988 (defun edebug-visit-eval-list ()
3989 "Switch to the evaluation list buffer \"*edebug*\"."
3979 (interactive) 3990 (interactive)
3980 (edebug-eval-redisplay) 3991 (edebug-eval-redisplay)
3981 (edebug-pop-to-buffer edebug-eval-buffer)) 3992 (edebug-pop-to-buffer edebug-eval-buffer))
3982 3993
3983 3994
4099 ;; else, could just display edebug-backtrace-buffer 4110 ;; else, could just display edebug-backtrace-buffer
4100 ) 4111 )
4101 (with-output-to-temp-buffer (buffer-name edebug-backtrace-buffer) 4112 (with-output-to-temp-buffer (buffer-name edebug-backtrace-buffer)
4102 (setq edebug-backtrace-buffer standard-output) 4113 (setq edebug-backtrace-buffer standard-output)
4103 (let ((print-escape-newlines t) 4114 (let ((print-escape-newlines t)
4104 (print-length 50) 4115 (print-length 50) ; FIXME cf edebug-safe-prin1-to-string
4105 last-ok-point) 4116 last-ok-point)
4106 (backtrace) 4117 (backtrace)
4107 4118
4108 ;; Clean up the backtrace. 4119 ;; Clean up the backtrace.
4109 ;; Not quite right for current edebug scheme. 4120 ;; Not quite right for current edebug scheme.
4167 (apply 'edebug-trace-display edebug-trace-buffer fmt args)) 4178 (apply 'edebug-trace-display edebug-trace-buffer fmt args))
4168 4179
4169 4180
4170 ;;; Frequency count and coverage 4181 ;;; Frequency count and coverage
4171 4182
4183 ;; FIXME should this use overlays instead?
4172 (defun edebug-display-freq-count () 4184 (defun edebug-display-freq-count ()
4173 "Display the frequency count data for each line of the current definition. 4185 "Display the frequency count data for each line of the current definition.
4174 The frequency counts are inserted as comment lines after each line, 4186 The frequency counts are inserted as comment lines after each line,
4175 and you can undo all insertions with one `undo' command. 4187 and you can undo all insertions with one `undo' command.
4176 4188