help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: debugging post command hook max-lisp-eval-depth


From: Stefan Monnier
Subject: Re: debugging post command hook max-lisp-eval-depth
Date: Sun, 17 Jun 2018 15:16:39 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> every now and then my Emacs will get in a bad state because of some
> infinite recursion in the post-command-hook. I am reaching out for ideas
> on how to debug Emacs when it gets into this weird state. Keep in mind
> that it is hard to do anything with Emacs at that point since any
> command (switching buffer, starting debugger) will fail with the same
> error `Lisp nesting exceeds...'.

Hmm... post-command-hook is run via `safe_run_hooks` which is supposed
to try and catch errors such that when an error is caught the
corresponding function is removed from post-command-hook.

Of course, this is a just a mitigating factor, but it should prevent the
problem you describe, except in those cases where the offending function
is constantly re-added (e.g. by a pre-command-hook).

Another approach is something like:

    (advice-add 'debug :around
      (lambda (&rest args)
        (let ((post-command-hook nil))
          (apply args))))


-- Stefan




reply via email to

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