]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid adding duplicate items to 'treesit-language-source-alist'.
authorJuri Linkov <juri@linkov.net>
Thu, 1 May 2025 17:55:33 +0000 (20:55 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 10 May 2025 06:54:46 +0000 (08:54 +0200)
* lisp/textmodes/mhtml-ts-mode.el:
* lisp/progmodes/php-ts-mode.el:
Use 'add-to-list' on items in language-source-alist
that should check for duplicate items.

* test/infra/Dockerfile.emba: Move multi-language mhtml-ts-mode and
php-ts-mode to the end to give their dependent grammars a lower priority.

* test/lisp/progmodes/js-tests.el (js-ts-mode-test-indentation):
Skip the test when 'jsdoc' is missing since 'js-ts-mode' depends
on the 'jsdoc' grammar.

(cherry picked from commit 5684a3808677fb701833c83325cd3bc8de475561)

lisp/progmodes/php-ts-mode.el
lisp/textmodes/mhtml-ts-mode.el
test/infra/Dockerfile.emba
test/lisp/progmodes/js-tests.el

index 8a739fc62c2d95120182cb81261f1f98cb8bde83..c13b31a439a0cd5f67bbb4e6450364a91eb4d375 100644 (file)
@@ -91,9 +91,8 @@
 You can customize `treesit-language-source-alist' if you want
 to stick to a specific commit and/or use different parsers.")
 
-(setq treesit-language-source-alist
-      (append treesit-language-source-alist
-              php-ts-mode--language-source-alist))
+(dolist (item php-ts-mode--language-source-alist)
+  (add-to-list 'treesit-language-source-alist item t))
 
 (defun php-ts-mode-install-parsers ()
   "Install all the required treesitter parsers.
index d8fdd1b19a632d9093e5fb39124ef1e472ebb673..5a29c9f0ee57abf4e2fb8ab676ac9500e228bac0 100644 (file)
@@ -73,9 +73,8 @@
 You can customize `treesit-language-source-alist' if you want
 to stick to a specific commit and/or use different parsers.")
 
-(setq treesit-language-source-alist
-      (append treesit-language-source-alist
-              mhtml-ts-mode--language-source-alist))
+(dolist (item mhtml-ts-mode--language-source-alist)
+  (add-to-list 'treesit-language-source-alist item t))
 
 (defun mhtml-ts-mode-install-parsers ()
   "Install all the required treesitter parsers.
index 1c1fbfc361a24800ac67b28e749e468e2f2eb49f..c6aed2aeac902761fce8cc9a8cbfb8e0673b8593 100644 (file)
@@ -131,10 +131,10 @@ RUN src/emacs -Q --batch \
         (treesit-library-abi-version t) (treesit-library-abi-version))' \
     --eval '(setq treesit-extra-load-path (list "/root/.emacs.d/tree-sitter"))' \
     --eval '(dolist (feature (quote (c-ts-mode cmake-ts-mode csharp-mode \
-        dockerfile-ts-mode elixir-ts-mode go-ts-mode heex-ts-mode java-ts-mode \
-        js json-ts-mode lua-ts-mode php-ts-mode python ruby-ts-mode rust-ts-mode \
-        sh-script typescript-ts-mode css-mode html-ts-mode markdown-ts-mode \
-        mhtml-ts-mode toml-ts-mode yaml-ts-mode treesit-x))) (require feature))' \
+        dockerfile-ts-mode elixir-ts-mode heex-ts-mode go-ts-mode java-ts-mode \
+        js json-ts-mode lua-ts-mode python ruby-ts-mode rust-ts-mode sh-script \
+        typescript-ts-mode css-mode html-ts-mode markdown-ts-mode toml-ts-mode \
+        yaml-ts-mode mhtml-ts-mode php-ts-mode treesit-x))) (require feature))' \
     --eval '(dolist (lang (mapcar (quote car) treesit-language-source-alist)) \
         (treesit-install-language-grammar lang "/root/.emacs.d/tree-sitter"))' \
     --eval '(message "treesit-language-source-alist\n%s" \
index 7d7aa7562a3eafcf9bb037e84e328108dcebc302..1a7edc5735eeb3aaa8943561f53406aa107affea 100644 (file)
@@ -291,7 +291,7 @@ function bar() {
 ;;;; Tree-sitter tests.
 
 (ert-deftest js-ts-mode-test-indentation ()
-  (skip-unless (treesit-ready-p 'javascript))
+  (skip-unless (and (treesit-ready-p 'javascript) (treesit-ready-p 'jsdoc)))
   (ert-test-erts-file (ert-resource-file "js-ts-indents.erts")))
 
 (provide 'js-tests)