aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2011-09-19 17:14:23 -0400
committerStefan Monnier2011-09-19 17:14:23 -0400
commite24e27be18156e7af5e8ec15a723225dfc7e22da (patch)
tree84046ccfe3ba3cd9664893a83f761dd88b8daf74
parent345083b2cbbe0fec01a7d2c052bd20d723675e2a (diff)
downloademacs-e24e27be18156e7af5e8ec15a723225dfc7e22da.tar.gz
emacs-e24e27be18156e7af5e8ec15a723225dfc7e22da.zip
* lisp/emacs-lisp/debug.el (debugger-args): Give it a docstring.
(debugger-return-value): Signal an error if the debugging context does not await any return value.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/emacs-lisp/debug.el67
2 files changed, 45 insertions, 26 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 258b0067d98..91bf69aa7a6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12011-09-19 Stefan Monnier <monnier@iro.umontreal.ca> 12011-09-19 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * emacs-lisp/debug.el (debugger-args): Give it a docstring.
4 (debugger-return-value): Signal an error if the debugging context does
5 not await any return value.
6
3 * ps-mule.el (ps-mule-plot-string): Don't inf-loop (bug#5108). 7 * ps-mule.el (ps-mule-plot-string): Don't inf-loop (bug#5108).
4 * image-mode.el (image-toggle-display-text) 8 * image-mode.el (image-toggle-display-text)
5 (image-toggle-display-image): Stay away from evil `intangible'. 9 (image-toggle-display-image): Stay away from evil `intangible'.
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index 16258a5a3a1..d7021a46165 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -98,6 +98,16 @@ and `debugger-reenable' to temporarily disable debug-on-entry.")
98 98
99(defvar inhibit-trace) ;Not yet implemented. 99(defvar inhibit-trace) ;Not yet implemented.
100 100
101(defvar debugger-args nil
102 "Arguments with which the debugger was called.
103It is a list expected to take the form (CAUSE . REST)
104where CAUSE can be:
105- debug: called for entry to a flagged function.
106- t: called because of debug-on-next-call.
107- lambda: same thing but via `funcall'.
108- exit: called because of exit of a flagged function.
109- error: called because of `debug-on-error'.")
110
101;;;###autoload 111;;;###autoload
102(setq debugger 'debug) 112(setq debugger 'debug)
103;;;###autoload 113;;;###autoload
@@ -296,32 +306,33 @@ That buffer should be current already."
296 (insert "Debugger entered") 306 (insert "Debugger entered")
297 ;; lambda is for debug-on-call when a function call is next. 307 ;; lambda is for debug-on-call when a function call is next.
298 ;; debug is for debug-on-entry function called. 308 ;; debug is for debug-on-entry function called.
299 (cond ((memq (car debugger-args) '(lambda debug)) 309 (pcase (car debugger-args)
300 (insert "--entering a function:\n")) 310 ((or `lambda `debug)
301 ;; Exiting a function. 311 (insert "--entering a function:\n"))
302 ((eq (car debugger-args) 'exit) 312 ;; Exiting a function.
303 (insert "--returning value: ") 313 (`exit
304 (setq debugger-value (nth 1 debugger-args)) 314 (insert "--returning value: ")
305 (prin1 debugger-value (current-buffer)) 315 (setq debugger-value (nth 1 debugger-args))
306 (insert ?\n) 316 (prin1 debugger-value (current-buffer))
307 (delete-char 1) 317 (insert ?\n)
308 (insert ? ) 318 (delete-char 1)
309 (beginning-of-line)) 319 (insert ? )
310 ;; Debugger entered for an error. 320 (beginning-of-line))
311 ((eq (car debugger-args) 'error) 321 ;; Debugger entered for an error.
312 (insert "--Lisp error: ") 322 (`error
313 (prin1 (nth 1 debugger-args) (current-buffer)) 323 (insert "--Lisp error: ")
314 (insert ?\n)) 324 (prin1 (nth 1 debugger-args) (current-buffer))
315 ;; debug-on-call, when the next thing is an eval. 325 (insert ?\n))
316 ((eq (car debugger-args) t) 326 ;; debug-on-call, when the next thing is an eval.
317 (insert "--beginning evaluation of function call form:\n")) 327 (`t
318 ;; User calls debug directly. 328 (insert "--beginning evaluation of function call form:\n"))
319 (t 329 ;; User calls debug directly.
320 (insert ": ") 330 (_
321 (prin1 (if (eq (car debugger-args) 'nil) 331 (insert ": ")
322 (cdr debugger-args) debugger-args) 332 (prin1 (if (eq (car debugger-args) 'nil)
323 (current-buffer)) 333 (cdr debugger-args) debugger-args)
324 (insert ?\n))) 334 (current-buffer))
335 (insert ?\n)))
325 ;; After any frame that uses eval-buffer, 336 ;; After any frame that uses eval-buffer,
326 ;; insert a line that states the buffer position it's reading at. 337 ;; insert a line that states the buffer position it's reading at.
327 (save-excursion 338 (save-excursion
@@ -439,6 +450,10 @@ Enter another debugger on next entry to eval, apply or funcall."
439This is only useful when the value returned from the debugger 450This is only useful when the value returned from the debugger
440will be used, such as in a debug on exit from a frame." 451will be used, such as in a debug on exit from a frame."
441 (interactive "XReturn value (evaluated): ") 452 (interactive "XReturn value (evaluated): ")
453 (when (memq (car debugger-args) '(t lambda error debug))
454 (error "Cannot return a value %s"
455 (if (eq (car debugger-args) 'error)
456 "from an error" "at function entrance")))
442 (setq debugger-value val) 457 (setq debugger-value val)
443 (princ "Returning " t) 458 (princ "Returning " t)
444 (prin1 debugger-value) 459 (prin1 debugger-value)