2

The only way I know of printing a backtrace for errors in batch invocation of Emacs is by setting debug-on-error inline like so:

$ emacs -batch --eval "(setq debug-on-error t)" -f "my/foo-function"

Is there a more idiomatic method for displaying backtraces for errors in batch mode?

  • Have you considered building Emacs from source, setting the src directory as the root directory in the terminal and then running gdb and your Emacs batch invocation (with the Emacs executable being the newly built one that is called through gdb)? As I'm sure you are already aware, you can set specific breakpoints, etc. If you provide some more details regarding the type of error you are dealing with, other forum participants may be able to provide better answers. – lawlist Oct 27 '17 at 2:40
  • @lawlist I'm not dealing with any particular error, I'm just curious what other methods may exist to get Emacs to display a backtrace and not just the content of the error message itself (when operating in batch mode). The common issue is the error message containing inadequate information to judge the context of the error. – ebpa Oct 27 '17 at 4:35
3

Is there a more idiomatic method for displaying backtraces for errors in batch mode?

Nope, that's pretty much it. You can save a few characters by calling toggle-debug-on-error instead:

 emacs -batch -f toggle-debug-on-error -f "my/foo-function"
  • I use toggle-debug-on-error interactively, but I prefer (setq debug-on-error t) for programmatic use (clearer IMHO). – ebpa Oct 30 '17 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.