]> git.eshelyaron.com Git - emacs.git/commitdiff
Add python tree-sitter grammar data to 'treesit-language-source-alist'.
authorJuri Linkov <juri@linkov.net>
Wed, 30 Apr 2025 17:28:05 +0000 (20:28 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 1 May 2025 08:32:09 +0000 (10:32 +0200)
* lisp/progmodes/python.el (python-ts-mode):
Use 'treesit-ensure-installed' when it's fboundp.

(cherry picked from commit dbd168823794ef2173bb6eb894174bc0c1685cd9)

lisp/progmodes/python.el

index 18eddee32f70ca01f14c4095dd7fe77c705422e0..e9db1f6af0c86023857116f6c0d482b52498edd9 100644 (file)
 (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)