mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
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.
This commit is contained in:
parent
e2f7917152
commit
9e1e9fdff4
2 changed files with 13 additions and 15 deletions
|
|
@ -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"))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue