.dir-locals.el
About this file
Settings for the Emacs editor. When you open a file anywhere under this directory, Emacs
reads .dir-locals.el and applies the variables listed for that file’s mode. Here they
apply to C files only, and make Emacs indent the way the xv6 sources are written: two
spaces per level, no tab characters. Users of other editors get the same from
.editorconfig, and make fmt (.clang-format) enforces it.
The file is written in Emacs Lisp: a list whose first element names a major mode
(c-mode), followed by (variable . value) pairs.
Indentation for C files
c-mode: the settings below apply in Emacs’s mode for C files (.cand.h).indent-tabs-mode . nil: indent with spaces only. By default Emacs replaces each 8 columns of indentation with a tab character, which would mix tabs into xv6’s space-indented code.c-file-style . "bsd": use the indentation rules of the “bsd” style that Emacs’s C mode provides, a style in the tradition of BSD Unix code.c-basic-offset . 2: but indent each level by 2 columns, overriding the “bsd” style’s own width of 8. This is the indentation you see throughout xv6.