Directory Local Variables

Recently, someone posted a link to Artur Malabarba’s old blog. Sadly, Malabarba no longer posts to it but it still has a lot of good and relevant information. The link was to a Malabarba post about directory local variables.

The idea is that you can place various variables controlling Emacs in a file in a directory and those variables will apply only to other files in that directory (and its subdirectories). It’s ideal, for example, if you have a project directory and would like to apply some Emacs customizations to the project’s files. You can specify that variables should apply only to file having a specific major mode or to all files.

The file format is a tiny bit fussy but fortunately you can simply call add-dir-local-variable and it will prompt you for the necessary information and write it to the local variables file, creating it if necessary.

I really like the idea but it never seems to work for me. That’s mainly because almost all the customizations I want to make involve running some code—invoking a minor mode, for example. File local variables support this (see Malabarba’s post or the documentation for the details) but every time I try to use it I get error messages about exceeding maximum evaluation depth. I wrote about this back in October.

Malabarba’s post is short and well worth a read if you’re not familiar with directory local variables or have mostly forgotten the details.

This entry was posted in General and tagged . Bookmark the permalink.