GNU bug report logs - #61051
treesit-install-language-grammar can provide the default repository URL

Previous Next

Package: emacs;

Reported by: Dmitry Gutov <dgutov <at> yandex.ru>

Date: Wed, 25 Jan 2023 03:24:01 UTC

Severity: normal

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 61051 in the body.
You can then email your comments to 61051 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#61051; Package emacs. (Wed, 25 Jan 2023 03:24:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dmitry Gutov <dgutov <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 25 Jan 2023 03:24:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: treesit-install-language-grammar can provide the default repository
 URL
Date: Wed, 25 Jan 2023 05:23:37 +0200
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): "))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61051; Package emacs. (Wed, 25 Jan 2023 12:30:02 GMT) Full text and rfc822 format available.

Message #8 received at 61051 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 61051 <at> debbugs.gnu.org
Subject: Re: bug#61051: treesit-install-language-grammar can provide the
 default repository URL
Date: Wed, 25 Jan 2023 14:29:30 +0200
> Date: Wed, 25 Jan 2023 05:23:37 +0200
> From: Dmitry Gutov <dgutov <at> 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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61051; Package emacs. (Wed, 25 Jan 2023 14:02:02 GMT) Full text and rfc822 format available.

Message #11 received at 61051 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 61051 <at> debbugs.gnu.org
Subject: Re: bug#61051: treesit-install-language-grammar can provide the
 default repository URL
Date: Wed, 25 Jan 2023 16:00:48 +0200
On 25/01/2023 14:29, Eli Zaretskii wrote:
>> Date: Wed, 25 Jan 2023 05:23:37 +0200
>> From: Dmitry Gutov<dgutov <at> 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.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61051; Package emacs. (Wed, 25 Jan 2023 14:51:01 GMT) Full text and rfc822 format available.

Message #14 received at 61051 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 61051 <at> debbugs.gnu.org
Subject: Re: bug#61051: treesit-install-language-grammar can provide the
 default repository URL
Date: Wed, 25 Jan 2023 16:50:37 +0200
> Date: Wed, 25 Jan 2023 16:00:48 +0200
> Cc: 61051 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> 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.




Reply sent to Dmitry Gutov <dgutov <at> yandex.ru>:
You have taken responsibility. (Wed, 25 Jan 2023 15:24:03 GMT) Full text and rfc822 format available.

Notification sent to Dmitry Gutov <dgutov <at> yandex.ru>:
bug acknowledged by developer. (Wed, 25 Jan 2023 15:24:03 GMT) Full text and rfc822 format available.

Message #19 received at 61051-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 61051-done <at> debbugs.gnu.org
Subject: Re: bug#61051: treesit-install-language-grammar can provide the
 default repository URL
Date: Wed, 25 Jan 2023 17:23:31 +0200
On 25/01/2023 16:50, Eli Zaretskii wrote:
>> Date: Wed, 25 Jan 2023 16:00:48 +0200
>> Cc:61051 <at> debbugs.gnu.org
>> From: Dmitry Gutov<dgutov <at> 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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 23 Feb 2023 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 61 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.