Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I put arbitrary elisp code in .dir-locals.el? [duplicate]

Possible Duplicate:
How can I move php-mode settings from .emacs to .dir-locals.el?

In Emacs, one can set up a file to eval arbitrary code when it is opened (after prompting the user, of course) by putting something like the following in the local variables section at the end of the file:

;; Local Variables:
;; eval: (message "This is evaluated when the file is opened in emacs.")
;; End:

Emacs also has a feature for putting variables in a file called .dir-locals.el, and having those variables apply to any file in the directory. However, this file does not seem to support evaluation of arbitrary code. Is there a way to do this at the directory level?

like image 946
Ryan C. Thompson Avatar asked Feb 23 '12 20:02

Ryan C. Thompson


1 Answers

For the record, the answer is that you do the same thing as in file-local variables: assign to the fake variable eval. For example, to add my example as a dir-local eval, just do the following from the directory in question: (add-dir-local-variable nil 'eval '(message "This is evaluated when any file in this directory is opened in emacs."))

like image 79
Ryan C. Thompson Avatar answered Oct 13 '22 19:10

Ryan C. Thompson