The eval
pseudo-variable enables you to specify arbitrary elisp for evaluation with your local variables.
e.g. https://mcmap.net/q/1278438/-how-can-i-move-php-mode-settings-from-emacs-to-dir-locals-el
See EmacsWiki for more details.
Note that this is not a particularly useful mechanism for setting key bindings, as every buffer using the keymap in question will be affected. You would probably be better off using the dir-local config to enable a minor mode with the specific keymap for that project. Alternatively, you might adapt this approach to file-local bindings (but a minor mode would be nicer).
That being said...
A fairly minimal form is ((nil . ((eval . (progn BODY)))))
with BODY
being the expressions to be evaluated. Of course if BODY
is only a single expression, you do not need progn
.
The following therefore displays a message when you visit any file (under the directory in question):
((nil . ((eval . (message "hello")))))
The car of each list in the dir-locals form is generally a major mode symbol, or nil
(as in the above example) in which case the settings apply in any major mode.
The car can also specify a sub-directory string, in which case the cdr is another dir-locals form with settings applicable to that sub-dir.