I am working on a cmake project and I would like to set a directory variable containing the correct compile command. I added this to the root directory of the project in a .dir-locals.el file:

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((nil .
      ((indent-tabs-mode . t)
       (fill-column . 80)
       (compile-command . "cd build && make"))))

If I enter describe-variable for the variable fill-column, I get the message that This variable's value is directory-local, set by the file .... The variable is set from its default of 70 to 80 instead. However, the compile-command variable is unchanged. Is there a bug in the file?


The variable compile-command is not buffer local by default, thus you can not set it per buffer. To change this add the following to your init file:

(make-variable-buffer-local 'compile-command)

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.