[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 9e1e9fdff44 03/10: Refactor treesit-admin--verify-major-mode-quer
From: |
Yuan Fu |
Subject: |
master 9e1e9fdff44 03/10: Refactor treesit-admin--verify-major-mode-queries |
Date: |
Mon, 30 Dec 2024 03:24:09 -0500 (EST) |
branch: master
commit 9e1e9fdff44f047489d45ba4a73776cb0298574f
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
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.
---
admin/treesit-admin.el | 13 ++++++++-----
lisp/treesit.el | 15 +++++----------
2 files changed, 13 insertions(+), 15 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 @@
The source information are in the format of
`treesit-language-source-alist'. This is for development only.")
-(defun treesit-admin--verify-major-mode-queries (modes langs grammar-dir)
+(defun treesit-admin--verify-major-mode-queries (modes langs source-alist
grammar-dir)
"Verify font-lock queries in MODES.
LANGS is a list of languages, it should cover all the languages used by
-MODES. GRAMMAR-DIR is a temporary direction in which grammars are
-installed.
+major modes in MODES. SOURCE-ALIST should have the same shape as
+`treesit-language-source-alist'. GRAMMAR-DIR is a temporary direction
+in which grammars are installed.
If the font-lock queries work fine with the latest grammar, insert some
comments in the source file saying that the modes are known to work with
that version of grammar. At the end of the process, show a list of
queries that has problems with latest grammar."
(let ((treesit-extra-load-path (list grammar-dir))
- (treesit-language-source-alist treesit-admin--builtin-language-sources)
(treesit--install-language-grammar-full-clone t)
(treesit--install-language-grammar-blobless t)
(version-alist nil)
@@ -103,7 +103,9 @@ queries that has problems with latest grammar."
(mode-language-alist nil)
(file-modes-alist nil))
(dolist (lang langs)
- (let ((ver (treesit-install-language-grammar lang grammar-dir)))
+ (let* ((recipe (assoc lang source-alist))
+ (ver (apply #'treesit--install-language-grammar-1
+ (cons grammar-dir recipe))))
(if ver
(push (cons lang ver) version-alist)
(error "Cannot get version for %s" lang))))
@@ -200,6 +202,7 @@ queries that has problems with latest grammar."
(treesit-admin--verify-major-mode-queries
'(cmake-ts-mode dockerfile-ts-mode go-ts-mode ruby-ts-mode)
'(cmake dockerfile go ruby)
+ treesit-admin--builtin-language-sources
"/tmp/tree-sitter-grammars"))
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 73e7e5446d4..5e153bc6f78 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -4171,10 +4171,7 @@ executable programs, such as the C/C++ compiler and
linker.
Interactively, prompt for the directory in which to install the
compiled grammar files. Non-interactively, use OUT-DIR; if it's
nil, the grammar is installed to the standard location, the
-\"tree-sitter\" directory under `user-emacs-directory'.
-
-Return the git revision of the installed grammar, but it only works when
-`treesit--install-language-grammar-full-clone' is t."
+\"tree-sitter\" directory under `user-emacs-directory'."
(interactive (list (intern
(completing-read
"Language: "
@@ -4199,13 +4196,12 @@ Return the git revision of the installed grammar, but
it only works when
default-out-dir)
;; When called non-interactively, OUT-DIR should
;; default to DEFAULT-OUT-DIR.
- (or out-dir default-out-dir)))
- version)
+ (or out-dir default-out-dir))))
(when recipe
(condition-case err
(progn
- (setq version (apply #'treesit--install-language-grammar-1
- (cons out-dir recipe)))
+ (apply #'treesit--install-language-grammar-1
+ (cons out-dir recipe))
;; Check that the installed language grammar is loadable.
(pcase-let ((`(,available . ,err)
@@ -4226,8 +4222,7 @@ Return the git revision of the installed grammar, but it
only works when
(display-warning
'treesit
(format "Error encountered when installing language grammar: %s"
- err)))))
- version))
+ err)))))))
(defun treesit--language-git-revision (repo-dir)
"Return the Git revision of the repo in REPO-DIR.
- master updated (dc653bf0636 -> ec3f9434c7d), Yuan Fu, 2024/12/30
- master 9e1e9fdff44 03/10: Refactor treesit-admin--verify-major-mode-queries,
Yuan Fu <=
- master c9624c21117 05/10: Add treesit-admin--last-compatible-grammar-for-modes, Yuan Fu, 2024/12/30
- master d9cfe1fe92f 07/10: Add treesit-admin-generate-compatibility-report, Yuan Fu, 2024/12/30
- master a22730f4d78 01/10: Support COMMIT in treesit-language-source-alist, Yuan Fu, 2024/12/30
- master d5ad51f25fb 04/10: Add treesit-admin--find-latest-compatible-revision, Yuan Fu, 2024/12/30
- master e2f79171529 02/10: Refactor treesit--install-language-grammar-1, Yuan Fu, 2024/12/30
- master 0b1986ba524 08/10: Generate compatibility report for multiple Emacs versions, Yuan Fu, 2024/12/30
- master 732a1108b0b 09/10: Add verified grammar version comment for tree-sitter modes, Yuan Fu, 2024/12/30
- master ec3f9434c7d 10/10: Make typescript-ts-mode work with latest grammar, Yuan Fu, 2024/12/30
- master 5ec170985f4 06/10: ; Move treesit-admin into tree-sitter directory, Yuan Fu, 2024/12/30