diff options
author | Yuan Fu <casouri@gmail.com> | 2022-12-31 14:55:10 -0800 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2022-12-31 14:55:10 -0800 |
commit | 683746978061f3bfc12d4bf524c15649f7b290fa (patch) | |
tree | 792c97f887034bc45c547fff3c29eadfd9a59cd6 | |
parent | 0dc788aa013db1222918c2dfe2ffad3d17b4b9f6 (diff) | |
download | emacs-683746978061f3bfc12d4bf524c15649f7b290fa.tar.gz |
; Add REVISION to treesit-language-source-alist
This allows users to install a particular version or branch. Prompted
by bug#60427 and bug#60223.
* lisp/treesit.el (treesit-language-source-alist)
(treesit--install-language-grammar-1): Add REVISION.
-rw-r--r-- | lisp/treesit.el | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el index 477abf65fb9..52983ec0c90 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2619,11 +2619,14 @@ window." The value should be an alist where each element has the form - (LANG . (URL SOURCE-DIR CC C++)) + (LANG . (URL REVISION SOURCE-DIR CC C++)) Only LANG and URL are mandatory. LANG is the language symbol. URL is the Git repository URL for the grammar. +REVISION is the Git tag or branch of the desired version, +defaulting to the latest default branch. + SOURCE-DIR is the relative subdirectory in the repository in which the grammar's parser.c file resides, defaulting to \"src\". @@ -2680,7 +2683,7 @@ content as signal data, and erase buffer afterwards." (erase-buffer))) (defun treesit--install-language-grammar-1 - (out-dir lang url &optional source-dir cc c++) + (out-dir lang url &optional revision source-dir cc c++) "Install and compile a tree-sitter language grammar library. OUT-DIR is the directory to put the compiled library file. If it @@ -2688,7 +2691,7 @@ is nil, the \"tree-sitter\" directory under user's Emacs configuration directory is used (and automatically created if it does not exist). -For LANG, URL, SOURCE-DIR, GRAMMAR-DIR, CC, C++, see +For LANG, URL, REVISION, SOURCE-DIR, GRAMMAR-DIR, CC, C++, see `treesit-language-source-alist'. If anything goes wrong, this function signals an error." (let* ((lang (symbol-name lang)) @@ -2709,10 +2712,14 @@ function signals an error." (unwind-protect (with-temp-buffer (message "Cloning repository") - ;; git clone xxx --depth 1 --quiet workdir - (treesit--call-process-signal - "git" nil t nil "clone" url "--depth" "1" "--quiet" - workdir) + ;; git clone xxx --depth 1 --quiet [-b yyy] workdir + (if revision + (treesit--call-process-signal + "git" nil t nil "clone" url "--depth" "1" "--quiet" + "-b" revision workdir) + (treesit--call-process-signal + "git" nil t nil "clone" url "--depth" "1" "--quiet" + workdir)) ;; We need to go into the source directory because some ;; header files use relative path (#include "../xxx"). ;; cd "${sourcedir}" |