I have a python program that I edit in emacs. However, sometimes when I save it, it gets re-indented, and in doing so, messes up the indentation of sections, where I have some code and then some undented code (because the nested block ended) but the formatter decides that it should all be indented.
def foo():
if xyz:
abcd = defg
hijk()
if not wxyz:
pqrs()
sometimes becomes:
def foo():
if xyz:
abcd = defg
hijk()
if not wxyz:
pqrs()
So, I want to turn off whatever formatter is being run, without turning off the rest of "python mode".
However, I don't know what hook has installed the formatter and how to turn it off. My .emacs file is well over 10,000 lines long (when all the files I bring in are included) with all the code I have in it. But that's what you get when you have "lived in" emacs, since the 1980s and don't hesitate to customize it.
indent-regionorpython-indent-regionwhen saving, which indents the entire region line by line. You can try checking thewrite-file-functionsin python-mode. Another suggestion is to locate the problem by continuously commenting out configurations through binary search.apheleiapackage calls Black if installed. Cannot reproduce your description, on Emacs 29.1 and vscode. Do not remove the formatters, get the habit to use them, as there is the standard PEP8 referring to format. If such case as yours is frequent , try to simply add a blank line beforehijk().