There are cases Emacs wont print stack traces on error
How can I make elisp print a stack trace from my own code? (into the stdout/stderr for example)
Something like Python's traceback:
import traceback traceback.print_exc()
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
I'm not sure just what you're asking, but does using function
backtrace in your code, at the place where you want to see a backtrace, help?
C-h f says:
backtraceis a compiled Lisp function in
Print a trace of Lisp function calls currently active.
Output stream used is value of
(let ((debug-on-error t)) (error "test"))
emacs -Q --batch -l tmp/test.el the following is printed to stderr:
Debugger entered--Lisp error: (error "test") signal(error ("test")) error("test") (let ((debug-on-error t)) (error "test")) eval-buffer(#<buffer *load*> nil "/home/wasa/tmp/test.el" nil t) ; Reading at buffer position 44 load-with-code-conversion("/home/wasa/tmp/test.el" "/home/wasa/tmp/test.el" nil t) load("/home/wasa/tmp/test.el" nil t) command-line-1(("-l" "tmp/test.el")) command-line() normal-top-level()
If there's a situation where it doesn't work, chances are errors are inhibited by the code in question.