The real question is about disabling a minor mode, but just to answer the stated question of setting a buffer-local variable, it's as simple as this:
((python-mode . ((format-all-mode . nil))))
I.e. giving variables buffer-local values is what the most basic syntax of .dir-locals.el
is for. There is no need to complicate anything with eval
.
Note that if you ever use (eval . (setq VAR VALUE))
in a .dir-locals.el
file and VAR
is not already/automatically buffer-local, then you are setting the global value. I would suggest using setq-local
as standard in that situation.
In your case, and per the quoted docs, you need to:
Use the command format-all-mode to change this variable.
Where the command is the function itself, which is interactively callable via M-x
.
(Because changing the variable is not the real goal; the variable is merely intended to be a reflection of whether or not certain other functionality is active, and the function controls that functionality.)
So you would use eval
if you needed this to be a buffer-local thing, but you'd do that to call the function:
((python-mode . ((eval . (format-all-mode 0)))))
n.b. I'm also assuming that format-all-mode
is a buffer-local minor mode. If it's a global mode, then the above would disable its behaviour globally as soon as you visited a python file under that directory. (Global modes need to be handled on a case-by-case basis, as how they operate can be highly variable.)
Edit: From the comments, this particular case needed something different again, but a working solution turns out to be:
((python-mode . ((+format-on-save-enabled-modes . nil))))
I.e. in python-mode
buffers, for files under the dir-locals directory, we give +format-on-save-enabled-modes
the buffer-local value of nil
. Testing has confirmed that this has the desired effect of preventing the format-on-save behaviour for those files.