From 3b4ed02a60b85004866306d30537dd216ba8960d Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 30 Apr 2025 20:28:05 +0300 Subject: [PATCH] Add python tree-sitter grammar data to 'treesit-language-source-alist'. * lisp/progmodes/python.el (python-ts-mode): Use 'treesit-ensure-installed' when it's fboundp. (cherry picked from commit dbd168823794ef2173bb6eb894174bc0c1685cd9) --- lisp/progmodes/python.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 18eddee32f7..e9db1f6af0c 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -265,6 +265,11 @@ (declare-function treesit-node-parent "treesit.c") (declare-function treesit-node-prev-sibling "treesit.c") +(add-to-list + 'treesit-language-source-alist + '(python "https://github.com/tree-sitter/tree-sitter-python" "v0.23.6") + t) + ;; Avoid compiler warnings (defvar compilation-error-regexp-alist) (defvar outline-heading-end-regexp) @@ -7224,7 +7229,9 @@ implementations: `python-mode' and `python-ts-mode'." \\{python-ts-mode-map}" :syntax-table python-mode-syntax-table - (when (treesit-ready-p 'python) + (when (if (fboundp 'treesit-ensure-installed) ; Emacs 31 + (treesit-ensure-installed 'python) + (treesit-ready-p 'python)) (setq treesit-primary-parser (treesit-parser-create 'python)) (setq-local treesit-font-lock-feature-list '(( comment definition) -- 2.39.5