I have blacken-mode
enabled on all python buffers like this:
(add-hook 'python-mode-hook
(lambda ()
(blacken-mode 1)
;; other config
))
But on some existing projects, where black
is not used, I don't want it on by default. I would like to enable blacken-mode
per buffer manually.
So I attempted to disable blacken-mode
in a project by adding the following .dir-locals.el
:
((python-mode . ((blacken-mode . nil))))
However, the behaviour I get is strange. When I open a Python file (after marking the directory local variables as safe), edit, and save. black
still reformats it, however running M-x blacken-mode
RET I get the message "Blacken mode enabled in current buffer". So I have to repeat M-xblacken-mode
RET, and then I get "Blacken mode disabled in current buffer", after that black
does not reformat the buffer any more.
So the directory local variables are getting picked up, but it doesn't behave the way I'm expecting. What am I doing wrong?