4

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?

ebpa
  • 7,319
  • 26
  • 53
  • 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 02: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 04:35

1 Answers1

5

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"
npostavs
  • 9,033
  • 1
  • 21
  • 53
  • 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 05:46