I'm trying to define a new major mode using define-generic-mode and want to try reusing c-indent-line-or-region for my indent-line-function. I've inserted

(set (make-local-variable 'indent-line-function) 'c-indent-line-or-region)

in the initialisation part of define-generic-mode and it is correctly set. However, when I hit enter in a buffer using that mode I get an error:

c-indent-line-or-region: Variable binding depth exceeds max-specpdl-size

I've searched around and found suggestions to enable debug-on-error, which I have done, but the *Backtrace* buffer is always empty and accompanied by a message

Lisp nesting exceeds max-lisp-eval-depth'

How should I go about debugging this?

  • This means that you've exceeded Emacs's recursion limits. You can debug by just setting those variables to large numbers (e.g. (setq max-lisp-eval-depth 10000)) or by just adding (message ...) calls and watching where the recursion blows up.
    – PythonNut
    May 6 '15 at 19:07
  • Right, I thought that this was just another symptom of the same problem, but increasing max-lisp-eval-depth helped, thanks. I found that if you set indent-line-function to c-indent-line-or-region it is asking for trouble as it calls to c-indent-command, indent-function, indent-according-to-mode, and then back to indent-line-function. May 7 '15 at 9:26

Your Answer

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

Browse other questions tagged or ask your own question.