Assuming I customized my default C indentation settings through M-x customize-variable c-offsets-alist:

    ((statement-case-open . 0)
     (substatement-open . 0)
     (case-label . +)
     (access-label . -)
     (label . 0)
     (arglist-intro . +)
     (arglist-cont . 0)
     (arglist-cont-nonempty . +)
     (arglist-close . 0)))))

When I want to edit a project using a specific indentation file, there is (or I can create) a .dir-locals.el indicating it:

((c-mode . ((c-file-style . "GNU"))))

However, the c-offsets-alist from my configuration still override the c-file-style defaults.

I've tried setting c-file-offsets and c-offsets-alist in .dir-locals, but it didn't work; setting c-file-offsets to nil had no effect, and setting c-offsets-alist to nil completely disables indentation.

Is it possible to disable c-offsets-alist from having an effect when c-file-style is non-nil?


Instead of modifying c-offsets-alist, you can modify c-file-offsets whose purpose is to set offsets via file local variables.

A small example for a .dir-locals.el file:

((nil . ((fill-column . 80)))
  (c-mode . ((c-file-style . "GNU")
              (brace-list-intro . +)))))

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.