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.
This commit is contained in:
Mattias Engdegård 2022-11-30 13:12:38 +01:00
parent dc0f2ec2db
commit af1a99d53f

View 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