]> git.eshelyaron.com Git - emacs.git/commitdiff
Sink python indent offset guessing to avoid test failure
authorMattias Engdegård <mattiase@acm.org>
Wed, 30 Nov 2022 12:12:38 +0000 (13:12 +0100)
committerMattias Engdegård <mattiase@acm.org>
Wed, 30 Nov 2022 12:22:04 +0000 (13:22 +0100)
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

index acfee21135801a9f2bdb242649688e7ce41bef5b..fc80c755e4376ef7c1cab876dcc567405e1a006c 100644 (file)
@@ -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