aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorJuri Linkov2025-08-29 19:27:32 +0300
committerJuri Linkov2025-08-29 19:27:32 +0300
commitb8ad7c38aebeb457f81e8298d9be10d9d30f2921 (patch)
treebbfb41049786230178ed78d09a8971b7f6e488e6 /lisp/progmodes/python.el
parentf7188ed77f82b71e856e21aab6c266f68bf21ee2 (diff)
downloademacs-b8ad7c38aebeb457f81e8298d9be10d9d30f2921.tar.gz
emacs-b8ad7c38aebeb457f81e8298d9be10d9d30f2921.zip
* lisp/progmodes/python.el: Use 'treesit-major-mode-remap-alist'.
(python-ts-mode): Don't duplicate 'auto-mode-alist' and 'interpreter-mode-alist' settings in Emacs 31 (bug#79180). Add ts-mode mapping to 'treesit-major-mode-remap-alist'.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 3cd20d6babf..649f47f6e69 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -7424,12 +7424,19 @@ implementations: `python-mode' and `python-ts-mode'."
7424 (when python-indent-guess-indent-offset 7424 (when python-indent-guess-indent-offset
7425 (python-indent-guess-indent-offset)) 7425 (python-indent-guess-indent-offset))
7426 7426
7427 (add-to-list 'auto-mode-alist (cons python--auto-mode-alist-regexp 'python-ts-mode)) 7427 (unless (boundp 'treesit-major-mode-remap-alist) ; Emacs 31.1
7428 (add-to-list 'interpreter-mode-alist '("python[0-9.]*" . python-ts-mode)))) 7428 (add-to-list 'auto-mode-alist (cons python--auto-mode-alist-regexp 'python-ts-mode))
7429 (add-to-list 'interpreter-mode-alist '("python[0-9.]*" . python-ts-mode)))))
7429 7430
7430(when (fboundp 'derived-mode-add-parents) ; Emacs 30.1 7431(when (fboundp 'derived-mode-add-parents) ; Emacs 30.1
7431 (derived-mode-add-parents 'python-ts-mode '(python-mode))) 7432 (derived-mode-add-parents 'python-ts-mode '(python-mode)))
7432 7433
7434;;;###autoload
7435(when (and (fboundp 'treesit-available-p) (treesit-available-p)
7436 (boundp 'treesit-major-mode-remap-alist)) ; Emacs 31.1
7437 (add-to-list 'treesit-major-mode-remap-alist
7438 '(python-mode . python-ts-mode)))
7439
7433;;; Completion predicates for M-x 7440;;; Completion predicates for M-x
7434;; Commands that only make sense when editing Python code. 7441;; Commands that only make sense when editing Python code.
7435(dolist (sym '(python-add-import 7442(dolist (sym '(python-add-import