My company has very specific indentation rules for C code. I want to create a style from those rules, and have it load at startup.

Doing a C/Guess Style From This Buffer and C/Install Last Guessed Style works great. It indents properly. But it goes away when I exit Emacs, and I have to guess and install the style again.

So I a did a C/View Last Guessed Style. I get a buffer with a very long lisp expression (78 lines) starting with

(c-add-style "STYLE NAME HERE"
               (c-basic-offset . 3)     ; Guessed value
                (arglist-cont . 0)      ; Guessed value
                (arglist-intro . ++)    ; Guessed value

I was a little confused why it asked me to enter a style name when I already did, and it listed it in the lisp (as I show above), but I changed the style name to what I wanted, which was identical to style-name-I-installed-interactively.

When I evaluate this buffer, everything is fine, but when I go to set the style (C-c .), I see

c-get-style-variables: Variable binding depth exceeds max-specpdl-size

While composing this and doing my due diligence, I solved my problem. For some reason, Emacs generated the expression with the name I chose to name the style as the base style, and because I specified the same name for both the base style and the added style name, it got into an infinite recursion loop in c-get-style-variables when it tried to evaluate things. (I figured this out by doing M-: (debug (c-set-style "style-name-I-installed-interactively")) and looking at the backtrace.) Removing the second "style-name-I-installed-interactively", which turns out to be optional, solved my problem.

So for people who see c-get-style-variables: Variable binding depth exceeds max-specpdl-size, elisp stack overflow is one potential cause.

| improve this answer | |

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.