13

I ran a command and received a warning in the minibuffer.

The exact warning was comint-completion-at-point failed to return valid completion data, after I autocompleted a command in shell-mode.

How can I determine the elisp origin of the warning?

Constantine
  • 9,122
  • 1
  • 35
  • 50
Matthew Piziak
  • 6,038
  • 3
  • 31
  • 79

1 Answers1

19

As pointed out in the other answer you'll find the fine manual useful for all the debug tools it has. For you specific problem I'd consider:

(setq debug-on-message "comint-completion-at-point failed to return valid completion data")

As the help text states:

If non-nil, debug if a message matching this regexp is displayed.

From this you should get a backtrace when the failure hits. You can then instrument the functions in question with C-u C-M-x and step through the failure next time it occurs for more information.

stsquad
  • 4,651
  • 29
  • 45
  • 3
    This is an excellent answer. Thank you. I think you have an extra quote in your first line, where you combine setq and 'debug-on-message. Changing it to setq debug-on-message or set 'debug-on-message fixed it for me. – Matthew Piziak Dec 11 '14 at 17:11
  • @MatthewPiziak: thanks - overzealous quoting fixed. – stsquad Dec 11 '14 at 22:47
  • This is so much better than zgrepping the Emacs compressed sources! Only downside of this is that the problematic condition must occur before one can debug it. –  Dec 25 '19 at 12:26
  • That doesn't appear to work (at least for Warning (emacs) messages) — Perhaps because these are generated from a place in the C code where the debugger won't work? – DomQ Feb 22 '24 at 10:39
  • @DomQ usually these messages come from (warn MESSAGE &rest ARGS) call somewhere in the elisp source so I would just grep for such a call first. Another possible scenario is that warn is called when a special error type user-error happens. This error type does not trigger the debugger (even with toggle-debug-on-error enabled) because it is in the debug-ignored-errors list. Removing user-error from debug-ignored-errors will enter debug mode at the point when warnings are issued. Good luck with debugging:) – Stas Mar 23 '24 at 19:26