I’ve been working with Strongswan for a while now and created a few patches to enhance conftest, the testing framework included in Strongswan. Like most software projects, Strongswan requires that patches adhere to their coding style. I wanted to configure my Emacs to take care of that, but only for the Strongswan source directory because I usually use a different style. The main difference is that Strongswan uses 4 character wide tabs. I quickly found that it is possible to put local Emacs settings into a
.dir-locals.el file, which applies to everything contained in its parent directory. Finding the actual tab with and indentation settings took a bit more time, but here’s my solution:
;; local indentation settings ((nil . ((indent-tabs-mode . t) (c-basic-offset . 4) (tab-width . 4))))
The first word behind the opening parentheses selects the mode where the settings will apply. In this case it’s
nil, so they will be used in all modes.