unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61051: treesit-install-language-grammar can provide the default repository URL
@ 2023-01-25  3:23 Dmitry Gutov
  2023-01-25 12:29 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2023-01-25  3:23 UTC (permalink / raw)
  To: 61051

The format https://github.com/tree-sitter/tree-sitter-%s will work for a 
lot of languages, and the user won't even have to search for the address.

The patch can look like this:

diff --git a/lisp/treesit.el b/lisp/treesit.el
index 660039cc7cc..c1b98d085e8 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -2708,7 +2708,8 @@ treesit--install-language-grammar-build-recipe
        (list
         lang
         (read-string
-        "Enter the URL of the Git repository of the language grammar: ")
+        "Enter the URL of the Git repository of the language grammar: "
+        (format "https://github.com/tree-sitter/tree-sitter-%s" lang))
         (empty-string-to-nil
          (read-string
           "Enter the tag or branch (default: default branch): "))





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#61051: treesit-install-language-grammar can provide the default repository URL
  2023-01-25  3:23 bug#61051: treesit-install-language-grammar can provide the default repository URL Dmitry Gutov
@ 2023-01-25 12:29 ` Eli Zaretskii
  2023-01-25 14:00   ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2023-01-25 12:29 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 61051

> Date: Wed, 25 Jan 2023 05:23:37 +0200
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> The format https://github.com/tree-sitter/tree-sitter-%s will work for a 
> lot of languages, and the user won't even have to search for the address.
> 
> The patch can look like this:
> 
> diff --git a/lisp/treesit.el b/lisp/treesit.el
> index 660039cc7cc..c1b98d085e8 100644
> --- a/lisp/treesit.el
> +++ b/lisp/treesit.el
> @@ -2708,7 +2708,8 @@ treesit--install-language-grammar-build-recipe
>         (list
>          lang
>          (read-string
> -        "Enter the URL of the Git repository of the language grammar: ")
> +        "Enter the URL of the Git repository of the language grammar: "
> +        (format "https://github.com/tree-sitter/tree-sitter-%s" lang))
>          (empty-string-to-nil
>           (read-string
>            "Enter the tag or branch (default: default branch): "))

Sounds good, but wouldn't we confuse users in those cases where the
Tree-sitter site doesn't have a grammar?  Would it be perhaps feasible
to probe first that a Git repository at the URL exists?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#61051: treesit-install-language-grammar can provide the default repository URL
  2023-01-25 12:29 ` Eli Zaretskii
@ 2023-01-25 14:00   ` Dmitry Gutov
  2023-01-25 14:50     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2023-01-25 14:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61051

On 25/01/2023 14:29, Eli Zaretskii wrote:
>> Date: Wed, 25 Jan 2023 05:23:37 +0200
>> From: Dmitry Gutov<dgutov@yandex.ru>
>>
>> The formathttps://github.com/tree-sitter/tree-sitter-%s  will work for a
>> lot of languages, and the user won't even have to search for the address.
>>
>> The patch can look like this:
>>
>> diff --git a/lisp/treesit.el b/lisp/treesit.el
>> index 660039cc7cc..c1b98d085e8 100644
>> --- a/lisp/treesit.el
>> +++ b/lisp/treesit.el
>> @@ -2708,7 +2708,8 @@ treesit--install-language-grammar-build-recipe
>>          (list
>>           lang
>>           (read-string
>> -        "Enter the URL of the Git repository of the language grammar: ")
>> +        "Enter the URL of the Git repository of the language grammar: "
>> +        (format"https://github.com/tree-sitter/tree-sitter-%s"  lang))
>>           (empty-string-to-nil
>>            (read-string
>>             "Enter the tag or branch (default: default branch): "))
> Sounds good, but wouldn't we confuse users in those cases where the
> Tree-sitter site doesn't have a grammar?  Would it be perhaps feasible
> to probe first that a Git repository at the URL exists?

Sure, how about this:

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 @@ treesit--install-language-grammar-build-recipe
                    (if (equal string "") nil string)))
        (list
         lang
-       (read-string
-        "Enter the URL of the Git repository of the language grammar: ")
+       (let ((repo-default (format 
"https://github.com/tree-sitter/tree-sitter-%s" lang)))
+         (read-string
+          "Enter the URL of the Git repository of the language grammar: "
+          (and (treesit--check-repo-url repo-default) repo-default)))
         (empty-string-to-nil
          (read-string
           "Enter the tag or branch (default: default branch): "))
@@ -2722,6 +2724,16 @@ treesit--install-language-grammar-build-recipe
          (read-string
           "Enter the C++ compiler to use (default: auto-detect): "))))))

+(defun treesit--check-repo-url (url)
+  (defvar url-request-method)
+  (let ((url-request-method "HEAD"))
+    (let ((buffer (condition-case nil (url-retrieve-synchronously url t t)
+                    (file-error nil))))
+      (and buffer
+           (eql
+            (buffer-local-value 'url-http-response-status buffer)
+            200)))))
+
  ;;;###autoload
  (defun treesit-install-language-grammar (lang)
    "Build and install the tree-sitter language grammar library for LANG.






^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#61051: treesit-install-language-grammar can provide the default repository URL
  2023-01-25 14:00   ` Dmitry Gutov
@ 2023-01-25 14:50     ` Eli Zaretskii
  2023-01-25 15:23       ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2023-01-25 14:50 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 61051

> Date: Wed, 25 Jan 2023 16:00:48 +0200
> Cc: 61051@debbugs.gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> >> -        "Enter the URL of the Git repository of the language grammar: ")
> >> +        "Enter the URL of the Git repository of the language grammar: "
> >> +        (format"https://github.com/tree-sitter/tree-sitter-%s"  lang))
> >>           (empty-string-to-nil
> >>            (read-string
> >>             "Enter the tag or branch (default: default branch): "))
> > Sounds good, but wouldn't we confuse users in those cases where the
> > Tree-sitter site doesn't have a grammar?  Would it be perhaps feasible
> > to probe first that a Git repository at the URL exists?
> 
> Sure, how about this:

LGTM, thanks.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#61051: treesit-install-language-grammar can provide the default repository URL
  2023-01-25 14:50     ` Eli Zaretskii
@ 2023-01-25 15:23       ` Dmitry Gutov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Gutov @ 2023-01-25 15:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61051-done

On 25/01/2023 16:50, Eli Zaretskii wrote:
>> Date: Wed, 25 Jan 2023 16:00:48 +0200
>> Cc:61051@debbugs.gnu.org
>> From: Dmitry Gutov<dgutov@yandex.ru>
>>
>>>> -        "Enter the URL of the Git repository of the language grammar: ")
>>>> +        "Enter the URL of the Git repository of the language grammar: "
>>>> +        (format"https://github.com/tree-sitter/tree-sitter-%s"   lang))
>>>>            (empty-string-to-nil
>>>>             (read-string
>>>>              "Enter the tag or branch (default: default branch): "))
>>> Sounds good, but wouldn't we confuse users in those cases where the
>>> Tree-sitter site doesn't have a grammar?  Would it be perhaps feasible
>>> to probe first that a Git repository at the URL exists?
>> Sure, how about this:
> LGTM, thanks.

Installed, thank you.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-25 15:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25  3:23 bug#61051: treesit-install-language-grammar can provide the default repository URL Dmitry Gutov
2023-01-25 12:29 ` Eli Zaretskii
2023-01-25 14:00   ` Dmitry Gutov
2023-01-25 14:50     ` Eli Zaretskii
2023-01-25 15:23       ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).