From af1a99d53f2ac5017b7a016f1ef2bce57c28a5b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Wed, 30 Nov 2022 13:12:38 +0100 Subject: [PATCH] Sink python indent offset guessing to avoid test failure Call python-indent-guess-indent-offset late in the set-up of python-mode and python-ts-mode to make sure that the required other settings (of syntax-propetize-function in particular) have been carried out. This cures a python-test failure (bug#59477). * lisp/progmodes/python.el (python-base-mode): Move python-indent-guess-indent-offset call from here... (python-mode): ...to here... (python-ts-mode): ...and here. --- lisp/progmodes/python.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index acfee211358..fc80c755e43 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -6584,9 +6584,6 @@ implementations: `python-mode' and `python-ts-mode'." (make-local-variable 'python-shell-internal-buffer) - (when python-indent-guess-indent-offset - (python-indent-guess-indent-offset)) - (add-hook 'flymake-diagnostic-functions #'python-flymake nil t)) ;;;###autoload @@ -6605,7 +6602,11 @@ implementations: `python-mode' and `python-ts-mode'." python-syntax-propertize-function) (setq-local imenu-create-index-function #'python-imenu-create-index) - (add-hook 'which-func-functions #'python-info-current-defun nil t)) + + (add-hook 'which-func-functions #'python-info-current-defun nil t) + + (when python-indent-guess-indent-offset + (python-indent-guess-indent-offset))) ;;;###autoload (define-derived-mode python-ts-mode python-base-mode "Python" @@ -6625,7 +6626,10 @@ implementations: `python-mode' and `python-ts-mode'." #'python-imenu-treesit-create-index) (setq-local treesit-defun-type-regexp (rx (or "function" "class") "_definition")) - (treesit-major-mode-setup))) + (treesit-major-mode-setup) + + (when python-indent-guess-indent-offset + (python-indent-guess-indent-offset)))) ;;; Completion predicates for M-x ;; Commands that only make sense when editing Python code -- 2.39.2