26 nov. 2022 kl. 23.18 skrev Yuan Fu : > 1. Setting require-final-newline to t doesn’t work As expected; it's not relevant here. > 2. If I change with-temp-buffer to with-current-buffer (get-buffer-create "*test*”), the problem disappears, the newlines is not dropped Yes, because you then reuse an old buffer that already has local variables set. I'm tempted to push this patch that sinks the call to python-indent-guess-indent-offset so that it comes last in mode initialisation, as discussed in my previous message. Any objection? As mentioned, I'm not sure it really addresses the root problem but at least it should be no worse than before the changes that broke the test.