I'd like to catch too big recursive call nesting in elisp, like this:

(condition-case nil
  (xxx (message "Gave up, using defaults")))

What is the symbol in place of xxx to catch too deep recursion?

  • Setting xxx to error would likely work. This would however depend on your settings for max-lisp-eval-depth if you lose your C-stack before you exceed max-lisp-eval-depth you cannot trigger the error. However, I guess you're looking for something to catch only the recursion error?
    – Xaldew
    Dec 1 '15 at 22:08
  • error is not bad in my case, but catching only the recursion error must be something doable, isn't it? Dec 2 '15 at 8:37
  • 1
    @GracjanPolak I don't think so, Emacs' error symbols tend to be very generic. I'd rather try to avoid hitting the error at all, either by rewriting into a while loop with a custom stack or by trampolining your way out of too deep recursion.
    – user227
    Dec 2 '15 at 15:22


(condition-case err
  (error (message "error=%S, data=%S" (car err) (cdr err))))

This will not only catch the error but will additionally emit a message telling you which specific error was signaled. Also, in recent Emacsen, you can use completion to see the possible error symbols.

Sadly, when you try the above, you'll see that the error signaled by excessive recursion is just error (aka the generic parent of all errors). You might like to M-x report-emacs-bug and request that this error be given a more specific symbol.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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