[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why post-command-hook so difficult to debug?

From: Stefan Monnier
Subject: Re: Why post-command-hook so difficult to debug?
Date: Tue, 28 Aug 2012 23:33:18 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

> For example, some days ago I was seeing this error:
> Error in post-command-hook (completion-in-region--postch):
> (wrong-type-argument characterp 134217855)

> and it turned out the error was generated by another function 100 miles
> from completion-in-region--postch. debug-on-error is mostly useless in
> this case.

> Can post-command-hook errors be more informative? Thanks.

Well, we could make debug-on-error work in post-command-hook, but that
will take some work.  If someone's interested, here are the problems to
- post-command-hook is run (via safe_run_hooks) in the equivalent of a
  (condition-case nil ... (t nil)), so debug-on-error is ignored because
  the errors are caught.  Maybe we can change debug-on-error to enter
  the debugger (rather than stay passive) when an error is caught by
  a `t' rather than by an `error' handler.
- post-command-hook is also run in the debugger, so in order to avoid
  recursively entering the debugger, we'll need to remove the currently
  executing function from post-command-hook before entering
  the debugger.
  I think the best way to do that is to add a new hook
  debug-let-bindings-functions whose functions return lists of (VAR
  . VAL) pairs that should be re-bound during debugging.  This way
  safe_run_hooks can add such a function to cause the current hook to be
  rebound temporarily with the debugged function removed.

-- Stefan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]