0

I've tried adding directory variables in several ways and I keep getting the same error. First, I was editing .dir.locals.el, but when that didn't work, I added each variable individually using M-x add-dir-local-variable.

Here is the code that was produced:

((nil
    (fill-column . 80)
    (tab-stop-list number-sequence 4 200 4)
    (tab-width . 4)))

This is the error I was getting:

Debugger entered--Lisp error: (invalid-function (nil (fill-column . 80) (tab-s$((nil (fill-column . 80) (tab-stop-list number-sequence 4 200 4) (tab-width $
 eval-region(98 186 t #[257 "\300\242b\210\301\207" [(186) ((nil (fill-column$ eval-defun-2()
eval-defun(nil)
call-interactively(eval-defun nil nil)
command-execute(eval-defun)

I've tried setting the local variable in the directory the one I'm trying to affect is located in and using the subdirectory instead of nil with no improvement. I've also tried just setting one local var at a time:

((nil
    (tab-width . 4)))

And using fully dotted pair notation:

((nil . ((tab-width . 4))))

And I'm still getting an error. Has anyone else encountered this error before? How do I fix it! I would love to be able to use directory variables on a project I'm working on! I'm working on a mac using Emacs 25.3.1, and I've in sshing into a linux machine with Emacs 24.5.1. I can't get my file to compile on either system. Any help would be greatly appreciated!

1 Answer 1

2

From the stack trace, it looks like you've tried to manually evaluate the form?

Despite the .el filename extension, .dir-locals.el is not code (it is data), and so it cannot be loaded or otherwise evaluated as code.

Just write the file and leave it -- it will take effect automatically whenever you visit a file under that directory.

For pre-existing file-visiting buffers, you can use M-x revert-buffer or similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.