diff options
| author | Yuan Fu | 2024-12-28 14:54:17 -0800 |
|---|---|---|
| committer | Yuan Fu | 2024-12-30 00:20:54 -0800 |
| commit | 9e1e9fdff44f047489d45ba4a73776cb0298574f (patch) | |
| tree | fe61fbbdc3933de1c1e8f242984cfe37610fbfd7 /admin | |
| parent | e2f791715299d97f401a38c75fa11bb51fdb8292 (diff) | |
| download | emacs-9e1e9fdff44f047489d45ba4a73776cb0298574f.tar.gz emacs-9e1e9fdff44f047489d45ba4a73776cb0298574f.zip | |
Refactor treesit-admin--verify-major-mode-queries
Make treesit-admin--verify-major-mode-queries use
treesit--install-language-grammar-1, rathre than the interactive
command treesit-install-language-grammar.
* admin/treesit-admin.el:
(treesit-admin--verify-major-mode-queries): Add parameter
SOURCE-ALIST. Use treesit--install-language-grammar-1.
(treesit-admin-verify-major-mode-queries): Pass
treesit-admin--builtin-language-sources to
treesit-admin--verify-major-mode-queries.
* lisp/treesit.el (treesit-install-language-grammar): Don't
return revision of the git repo.
Diffstat (limited to 'admin')
| -rw-r--r-- | admin/treesit-admin.el | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/admin/treesit-admin.el b/admin/treesit-admin.el index 440056aff21..36b8cb620b5 100644 --- a/admin/treesit-admin.el +++ b/admin/treesit-admin.el | |||
| @@ -82,19 +82,19 @@ | |||
| 82 | The source information are in the format of | 82 | The source information are in the format of |
| 83 | `treesit-language-source-alist'. This is for development only.") | 83 | `treesit-language-source-alist'. This is for development only.") |
| 84 | 84 | ||
| 85 | (defun treesit-admin--verify-major-mode-queries (modes langs grammar-dir) | 85 | (defun treesit-admin--verify-major-mode-queries (modes langs source-alist grammar-dir) |
| 86 | "Verify font-lock queries in MODES. | 86 | "Verify font-lock queries in MODES. |
| 87 | 87 | ||
| 88 | LANGS is a list of languages, it should cover all the languages used by | 88 | LANGS is a list of languages, it should cover all the languages used by |
| 89 | MODES. GRAMMAR-DIR is a temporary direction in which grammars are | 89 | major modes in MODES. SOURCE-ALIST should have the same shape as |
| 90 | installed. | 90 | `treesit-language-source-alist'. GRAMMAR-DIR is a temporary direction |
| 91 | in which grammars are installed. | ||
| 91 | 92 | ||
| 92 | If the font-lock queries work fine with the latest grammar, insert some | 93 | If the font-lock queries work fine with the latest grammar, insert some |
| 93 | comments in the source file saying that the modes are known to work with | 94 | comments in the source file saying that the modes are known to work with |
| 94 | that version of grammar. At the end of the process, show a list of | 95 | that version of grammar. At the end of the process, show a list of |
| 95 | queries that has problems with latest grammar." | 96 | queries that has problems with latest grammar." |
| 96 | (let ((treesit-extra-load-path (list grammar-dir)) | 97 | (let ((treesit-extra-load-path (list grammar-dir)) |
| 97 | (treesit-language-source-alist treesit-admin--builtin-language-sources) | ||
| 98 | (treesit--install-language-grammar-full-clone t) | 98 | (treesit--install-language-grammar-full-clone t) |
| 99 | (treesit--install-language-grammar-blobless t) | 99 | (treesit--install-language-grammar-blobless t) |
| 100 | (version-alist nil) | 100 | (version-alist nil) |
| @@ -103,7 +103,9 @@ queries that has problems with latest grammar." | |||
| 103 | (mode-language-alist nil) | 103 | (mode-language-alist nil) |
| 104 | (file-modes-alist nil)) | 104 | (file-modes-alist nil)) |
| 105 | (dolist (lang langs) | 105 | (dolist (lang langs) |
| 106 | (let ((ver (treesit-install-language-grammar lang grammar-dir))) | 106 | (let* ((recipe (assoc lang source-alist)) |
| 107 | (ver (apply #'treesit--install-language-grammar-1 | ||
| 108 | (cons grammar-dir recipe)))) | ||
| 107 | (if ver | 109 | (if ver |
| 108 | (push (cons lang ver) version-alist) | 110 | (push (cons lang ver) version-alist) |
| 109 | (error "Cannot get version for %s" lang)))) | 111 | (error "Cannot get version for %s" lang)))) |
| @@ -200,6 +202,7 @@ queries that has problems with latest grammar." | |||
| 200 | (treesit-admin--verify-major-mode-queries | 202 | (treesit-admin--verify-major-mode-queries |
| 201 | '(cmake-ts-mode dockerfile-ts-mode go-ts-mode ruby-ts-mode) | 203 | '(cmake-ts-mode dockerfile-ts-mode go-ts-mode ruby-ts-mode) |
| 202 | '(cmake dockerfile go ruby) | 204 | '(cmake dockerfile go ruby) |
| 205 | treesit-admin--builtin-language-sources | ||
| 203 | "/tmp/tree-sitter-grammars")) | 206 | "/tmp/tree-sitter-grammars")) |
| 204 | 207 | ||
| 205 | 208 | ||