diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-21 02:45:30 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-21 02:45:30 +0100 |
commit | 8c8790cb9731adb521c06dee7489218fc02029a6 (patch) | |
tree | 740e9c8e284c6d1bd46bdae7eabd14b75f80e288 | |
parent | 8377f5e282cf318a2af9fa8864aaf15ff2fb22ef (diff) | |
download | geiser-guile-8c8790cb9731adb521c06dee7489218fc02029a6.tar.gz geiser-guile-8c8790cb9731adb521c06dee7489218fc02029a6.tar.bz2 |
Capture backtrace. Fix load/compile from Emacs.
-rw-r--r-- | geiser/emacs.scm | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/geiser/emacs.scm b/geiser/emacs.scm index 382958d..d5e245b 100644 --- a/geiser/emacs.scm +++ b/geiser/emacs.scm @@ -37,16 +37,25 @@ ge:module-children ge:module-location) #:use-module (srfi srfi-1) + #:use-module (system base compile) #:use-module ((geiser introspection) :renamer (symbol-prefix-proc 'ge:))) (define (write-result result output) (write (list (cons 'result result) (cons 'output output))) (newline)) -(define (write-error key . args) - (write (list (cons 'error (apply parse-error (cons key args))))) +(define (write-error key args stack) + (write (list (cons 'error (apply parse-error (cons key args))) + (cons 'stack (parse-stack stack)))) (newline)) +(define (parse-stack stack) + (if stack + (list + (with-output-to-string + (lambda () (display-backtrace stack (current-output-port))))) + '())) + (define (parse-error key . args) (let* ((len (length args)) (subr (and (> len 0) (first args))) @@ -58,10 +67,11 @@ (cons 'msg (if msg (apply format (cons #f (cons msg margs))) '())) (cons 'rest (or rest '()))))) -(define (evaluate form module evaluator) +(define (evaluate form module-name evaluator) (let ((module (or (and (list? module-name) (resolve-module module-name)) - (current-module)))) + (current-module))) + (captured-stack #f)) (catch #t (lambda () (let ((result #f)) @@ -69,7 +79,8 @@ (lambda () (set! result (evaluator form module)))))) (write-result result output)))) - write-error))) + (lambda (key . args) (write-error key args captured-stack)) + (lambda (key . args) (set! captured-stack (make-stack #t)))))) (define (eval-compile form module) (save-module-excursion |