When I do (define (foo) (/ 1 0)) (set-trace-level! foo) ; these forms are defined in the attached (backtrack foo) ; snipped of texmacs' debug.scm I get the following output on the console (the first line is the output of the home-made trace). [foo] 1 [catch #t # #] 2* [#] 3* [object->string ... 4* [eval-string "(make-return)"] 5* [#] 6 (if (string-null? (get-env "return action")) (pass) ...) ... 7 [process-input] 8* [TeXmacs-guile-eval-any "(backtrack (foo))"] 9 [catch #t # #] 10* [#] 11* [object->string ... 12* [eval-string "(backtrack (foo))"] 13* (backtrack (foo)) 14 [lazy-catch #t # #] 15* [#] 16* [#] 17 [catch #t # #] 18* [# numerical-overflow "/" "Numerical overflow" #f #f] 19* [apply # #] 20 [apply # #] ERROR: In procedure apply in expression (apply throw err): ERROR: Numerical overflow It seems that the apply in wrap-trace-level is executed twice, and the second time it has invalid arguments. I could not find any way of preventing that strang behaviour, and that is very annoying. I tried wrapping the lazy catch in a (catch 'ignore-this ...) as in the provided example, but it did not help (and prevented the error going all the way up to the texmacs). Also I was unable to reproduce the problem in a simple guile interpreter because the built-in backtrace feature seems to get in the way of exception handling. Actually I would rather like to find a way to use the built-in trace feature, any idea? I am using guile-1.4.1. I know I should use a more recent release but we have a policy of supporting all guile versions from 1.3.4 (esp. the main developer of TeXmacs uses this version) so I rather not use guile-1.6 for development. Why it is all so dirty ========================= I know I should rather use the built-in tracing capability defined by (use-modules (ice-9 debug)) but (trace foo), where foo is some buggy function, does not seem to enable any tracing from within TeXmacs. I have tried enabling debugging as described there: http://www.masanjin.net/wiki/Wiki.jsp?page=IncorporatingGuileIntoYourCProgram by including the following snippet early in the application initialization: SCM_DEVAL_P = 1; SCM_BACKTRACE_P = 1; SCM_RECORD_POSITIONS_P = 1; SCM_RESET_DEBUG_MODE; But it does not seem to have any effect. Specifically it does not enable lazy-catch based backtrace display. On the other hand, including that statement: (debug-enable 'backtrace 'debug) early in the scheme environment initialization did activate backtraces inside lazy-catch, but did not allow me to use the built-in trace form. More context ============== For information, TeXmacs evaluates scheme commands using the following code (I admit it is pretty dumb): [this is part of the VERY early environment init] "(define (TeXmacs-guile-error-handler . args)\n" " (object->string args))\n" "\n" "(define (object->string obj)\n" " (call-with-output-string\n" " (lambda (port) (write obj port))))\n" "\n" "(define (TeXmacs-guile-eval-any s)\n" " (catch\n" " #t\n" " (lambda ()\n" " (object->string (eval-string s)))\n" " TeXmacs-guile-error-handler))\n" [this is the corresponding C++ code] bool eval_scheme_any (string s, string& r) { // cout << "Eval any] " << start (s) << "\n"; string prg= "(TeXmacs-guile-eval-any \"" * back_slash (s) * "\")"; char* _s= as_charp (prg); SCM result= gh_eval_str (_s); delete[] _s; int len_r; char* _r= scm2newstr (result, &len_r); r= _r; free (_r); if (r == "#") r= ""; // cout << "Yields] " << start (r) << "\n"; return false; } Please, help! -- David Allouche | GNU TeXmacs -- Writing is a pleasure Free software engineer | http://www.texmacs.org http://ddaa.net | http://alqua.com/tmresources david@allouche.net | allouche@texmacs.org TeXmacs is NOT a LaTeX front-end and is unrelated to emacs.