4

While debugging a minor mode (separate issue), I wanted to generate a stack trace of the message function so I thought I would just enter

M-x debug-on-entry RET message

I was quite surprised to see that this method did not work. No stack trace was generated instead I started to get the error

Lisp nesting exceeds `max-lisp-eval-depth'

Which probably means that the message function was being called from the debugger, and debugger was calling message again making an infinite loop. Is there a more fool-proof way of generating full traces of who called the message function ?

3
  • While I agree with @phils, this error you got was actually a bug, which I just fixed in Emacs's master branch.
    – Stefan
    Commented Mar 18, 2015 at 14:33
  • Was it this ? git.savannah.gnu.org/cgit/emacs.git/commit/….
    – Pushpendre
    Commented Mar 19, 2015 at 6:01
  • Yes, tho only the debug.el part.
    – Stefan
    Commented Mar 19, 2015 at 16:31

1 Answer 1

7

You want to use the debug-on-message variable in this situation.

If non-nil, debug if a message matching this regexp is displayed.
2
  • Good answer, was it easy to find in the docs ? I tried apropos but gave up maybe too quickly.
    – Pushpendre
    Commented Mar 18, 2015 at 3:40
  • 1
    It's certainly easy if you already know it's there :) I first spotted it in the NEWS file when 24.3 was released. Searching for "debug" with apropos finds it quickly enough, I think? In the manual you can find it under both (elisp) Error Debugging and also (elisp) Explicit Debug, and a repeated isearch for "message" in the debugger section turns it up pretty soon. So yeah... you probably gave up a bit early in this instance.
    – phils
    Commented Mar 18, 2015 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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