unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: jostein@kjonigsen.net
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Tree-sitter integration in python.el
Date: Tue, 27 Sep 2022 15:16:14 -0700	[thread overview]
Message-ID: <20432C20-8FB9-44D9-A91C-ACEEAE1CAD09@gmail.com> (raw)
In-Reply-To: <761f064e-3cbf-5ca7-2edb-4de6670345bf@secure.kjonigsen.net>



> On Sep 26, 2022, at 12:10 PM, Jostein Kjønigsen <jostein@secure.kjonigsen.net> wrote:
> 
> On 22.09.2022 20:42, Yuan Fu wrote:
>> Hi, 
>> 
>> I’ve added tree-sitter version for font-lock and which-func in python.el. And I’d love to hear some feedback from python.el maintainers. Specifically, does it look right and which other part of python.el could actually benefit from a parse tree? I wrote a tree-sitter imenu indexer for python and it performed worse than the current one, presumably because it traverses the whole parse tree whereas the current one only scans the buffer once or so and do some regex matching.
>> 
>> Here is the commit: 
>> https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=feature/tree-sitter&id=1cdb24fe35a9ff2e4f92c5acc93a5a5b0e70d93f
>> 
>> 
>> Yuan
>> 
>> 
>> 
> Hey Yuan.
> 
> Thanks for putting in all this work into tree-sitter in Emacs!
> 
> Trying the latest Emacs-version in feature/tree-sitter I got an error I tend to get "a lot" with tree-sitter based modes, which I hoped bundling things with Emacs would solve, namely obtaining the original shared-object containing the compiled grammer.
> 
> Like for your python-mode, I get this:
> 
> File mode specification error: (treesit-load-language-error python (/home/jostein/.emacs.d/tree-sitter/libtree-sitter-python: cannot open shared object file: No such file or directory /home/jostein/.emacs.d/tree-sitter/libtree-sitter-python.so: cannot open shared object file: No such file or directory libtree-sitter-python: cannot open shared object file: No such file or directory libtree-sitter-python.so: cannot open shared object file: No such file or directory))
> 
> I realize third-party modes are on their own, but when tree-sitter is compiled with Emacs, I would at least expect the Emacs-build to also produce these .so-files.
> 
> What are your thoughts on how we can best, across the Emacs-verse, provide these libraries? Or at least for the modes which are bundled with Emacs itself?
> 
> Being a tree-sitter based-developer myself, I know where I can go to get this compiled to make the mode runnable, but surely that's not how we can deploy this en-masse. Most people will be stuck at this point, and we will need to come up with a better answer.
> 
> -- 
>  Kind regards
> Jostein Kjønigsen
> 
> jostein@kjonigsen.net 🍵 jostein@gmail.com
> https://jostein.kjønigsen.no

This has been discussed before and our conclusion is to treat language definitions like other dynamic libraries, expecting package manager to install them. There are a couple of reasons. Tree-sitter library and language definitions must be on the same “protocol” version to work. I expect this version to change slowly, but in principle we don’t want to bundle a language definition that could conflict with the tree-sitter library provided by the system. Also, as a dynamic object file, it is machine-dependent. I don’t know if we bundle anything machine-dependent in Emacs distribution, but at any rate it is unusual. 

I do have some ideas to make it easier for users, like hosting them on ELPA or NONGNU ELPA, and user can install them by package-install. Eg, a package tree-sitter-installer-linux, and M-x tree-sitter-installer-linux RET c RET will install C language definition for you. Stefan, WDYT?

Yuan


  reply	other threads:[~2022-09-27 22:16 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 18:42 Tree-sitter integration in python.el Yuan Fu
2022-09-26 19:10 ` Jostein Kjønigsen
2022-09-27 22:16   ` Yuan Fu [this message]
2022-10-03 18:07 ` Matthias Meulien
2022-10-03 18:38   ` Eli Zaretskii
2022-10-03 22:19     ` Matthias Meulien
2022-10-03 22:31       ` Yuan Fu
2022-10-03 22:47         ` Matthias Meulien
2022-10-06  2:56           ` Yuan Fu
2022-10-06  7:18             ` Matthias Meulien
2022-10-06 18:26               ` Yuan Fu
2022-10-06 20:53                 ` Matthias Meulien
2022-10-07  8:25                   ` Yuan Fu
2022-10-07 10:03                     ` Augusto Stoffel
2022-10-07 17:53                       ` chad
2022-10-07 19:09                         ` Eli Zaretskii
2022-10-07 22:17                         ` Yuan Fu
2022-10-07 22:10                       ` Yuan Fu
2022-10-08  6:30                         ` Eli Zaretskii
2022-10-08 20:57                           ` Yuan Fu
2022-10-09  4:13                             ` Eli Zaretskii
2022-10-11 22:15                             ` Stefan Monnier
2022-10-12  5:04                               ` Yuan Fu
2022-10-12 17:52                                 ` Stefan Monnier
2022-10-12 22:55                                   ` Yuan Fu
2022-10-12 23:43                                     ` Yuan Fu
2022-10-13  0:16                                       ` [SPAM UNSURE] " Stephen Leake
2022-10-13  5:55                                       ` Eli Zaretskii
2022-10-15 23:15                                         ` Yuan Fu
2022-10-08  8:03                         ` Augusto Stoffel
2022-10-08 16:20                           ` [External] : " Drew Adams
2022-10-10 15:38                             ` Augusto Stoffel
2022-10-08 21:06                           ` Yuan Fu
2022-10-10  7:16                             ` Augusto Stoffel
2022-10-10 15:10                               ` Yuan Fu
2022-10-10 15:53                                 ` Augusto Stoffel
2022-10-12  5:08                                   ` Yuan Fu
2022-10-11 22:18                                 ` Stefan Monnier
2022-10-04  6:13       ` Eli Zaretskii
2022-10-04 11:21         ` Matthias Meulien
2022-10-04 12:33           ` Eli Zaretskii
2022-10-04 17:11             ` Matthias Meulien
2022-10-03 22:25   ` Yuan Fu
2022-10-16  7:31     ` Eli Zaretskii
2022-10-16  8:15       ` Yuan Fu
2022-10-16  8:18         ` Eli Zaretskii
2022-10-03 22:35 ` Matthias Meulien
  -- strict thread matches above, loose matches on Subject: below --
2022-10-03 21:53 lkg.ch@pm.me

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20432C20-8FB9-44D9-A91C-ACEEAE1CAD09@gmail.com \
    --to=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=jostein@kjonigsen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).