I have a project where I want to disable
format-all-mode for all my python files. I can do this manually by running
M-x format-all-mode every time I open up a python file for that project.
I tried automating this by setting my
.dir-locals.el to this:
((python-mode (eval . (progn (make-local-variable 'format-all-mode) (setq format-all-mode nil))) ))
I've also tried:
((python-mode (eval . (progn (format-all-mode nil))) ))
format-all-mode continues to be
t every time I open a python file. I've confirmed that my
.dir-locals.el settings are otherwise working, because when I add something like
(setq blah "asdf") inside the
progn function, I see that variable in my buffer.
What am I missing in order to configure the buffer-local
Here are the docs when I describe this
format-all-mode is a buffer-local variable defined in format-all.el. Value in #<buffer my-file.py> t Buffer values Global value Toggle Set Documentation Non-nil if Format-All mode is enabled. Use the command format-all-mode to change this variable. Key Bindings This command is not in any keymaps. References References in format-all.el: (define-minor-mode format-all-mode ...) 2 references Find all references
I should've mentioned that I'm using Doom emacs, which has modified the format-all-mode so that it cannot be disabled with the usual
I followed these instructions: https://docs.doomemacs.org/latest/modules/editor/format/
and got it working with the following value in my
((python-mode (eval . (progn ;; this doesn't work, because we're using doom emacs: ;; (format-all-mode -1) ;; ;; https://docs.doomemacs.org/latest/modules/editor/format/ ;; TODO: add python-mode to the list, instead of overwriting the whole list (setq +format-on-save-enabled-modes '(not python-mode sql-mode org-mode emacs-lisp-mode)) )) ))
It's a hack though, since
+format-on-save-enabled-modes isn't buffer local. I'm not sure if there's a better way - any help is appreciated!