[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 6837469780 2/3: ; Add REVISION to treesit-language-source-alist
From: |
Yuan Fu |
Subject: |
emacs-29 6837469780 2/3: ; Add REVISION to treesit-language-source-alist |
Date: |
Sat, 31 Dec 2022 20:10:15 -0500 (EST) |
branch: emacs-29
commit 683746978061f3bfc12d4bf524c15649f7b290fa
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
; 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.
---
lisp/treesit.el | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 477abf65fb..52983ec0c9 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}"