Posted by: Airtower | 2013-01-12

Set Tab Width for Indentation in Emacs

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.

Advertisements

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: