diff options
| author | Dmitry Gutov | 2023-01-25 17:01:28 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2023-01-25 17:22:31 +0200 |
| commit | abb3becb9fb925a4fc3c13da677cc55823423cb3 (patch) | |
| tree | 57af5cc35f82b4a9be2325ad8a32c9e76a64ac6d | |
| parent | c6613403e5cb5e2f0043d16530be046922d23f43 (diff) | |
| download | emacs-abb3becb9fb925a4fc3c13da677cc55823423cb3.tar.gz emacs-abb3becb9fb925a4fc3c13da677cc55823423cb3.zip | |
treesit-install-language-grammar: Provide default repo url
* lisp/treesit.el (treesit--check-repo-url): New function.
(treesit--install-language-grammar-build-recipe): Use it (bug#61051).
| -rw-r--r-- | lisp/treesit.el | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el index 660039cc7cc..4c9bdfc0bd4 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el | |||
| @@ -2707,8 +2707,10 @@ See `treesit-language-source-alist' for details." | |||
| 2707 | (if (equal string "") nil string))) | 2707 | (if (equal string "") nil string))) |
| 2708 | (list | 2708 | (list |
| 2709 | lang | 2709 | lang |
| 2710 | (read-string | 2710 | (let ((repo-default (format "https://github.com/tree-sitter/tree-sitter-%s" lang))) |
| 2711 | "Enter the URL of the Git repository of the language grammar: ") | 2711 | (read-string |
| 2712 | "Enter the URL of the Git repository of the language grammar: " | ||
| 2713 | (and (treesit--check-repo-url repo-default) repo-default))) | ||
| 2712 | (empty-string-to-nil | 2714 | (empty-string-to-nil |
| 2713 | (read-string | 2715 | (read-string |
| 2714 | "Enter the tag or branch (default: default branch): ")) | 2716 | "Enter the tag or branch (default: default branch): ")) |
| @@ -2722,6 +2724,16 @@ See `treesit-language-source-alist' for details." | |||
| 2722 | (read-string | 2724 | (read-string |
| 2723 | "Enter the C++ compiler to use (default: auto-detect): ")))))) | 2725 | "Enter the C++ compiler to use (default: auto-detect): ")))))) |
| 2724 | 2726 | ||
| 2727 | (defun treesit--check-repo-url (url) | ||
| 2728 | (defvar url-request-method) | ||
| 2729 | (let ((url-request-method "HEAD")) | ||
| 2730 | (let ((buffer (condition-case nil (url-retrieve-synchronously url t t) | ||
| 2731 | (file-error nil)))) | ||
| 2732 | (and buffer | ||
| 2733 | (eql | ||
| 2734 | (buffer-local-value 'url-http-response-status buffer) | ||
| 2735 | 200))))) | ||
| 2736 | |||
| 2725 | ;;;###autoload | 2737 | ;;;###autoload |
| 2726 | (defun treesit-install-language-grammar (lang) | 2738 | (defun treesit-install-language-grammar (lang) |
| 2727 | "Build and install the tree-sitter language grammar library for LANG. | 2739 | "Build and install the tree-sitter language grammar library for LANG. |