From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter integration in python.el Date: Mon, 3 Oct 2022 15:31:53 -0700 Message-ID: References: <3A68545C-2E40-4BB4-8563-8041A5452634@gmail.com> <87y1twlr0v.fsf@gmail.com> <83czb8ycpo.fsf@gnu.org> <87tu4klfcw.fsf@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19178"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Matthias Meulien Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Oct 04 00:35:01 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofU1c-0004pr-Ft for ged-emacs-devel@m.gmane-mx.org; Tue, 04 Oct 2022 00:35:00 +0200 Original-Received: from localhost ([::1]:58798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ofU1b-0004SI-Dy for ged-emacs-devel@m.gmane-mx.org; Mon, 03 Oct 2022 18:34:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofTyi-0002AR-OD for emacs-devel@gnu.org; Mon, 03 Oct 2022 18:32:06 -0400 Original-Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:43615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ofTyf-00039N-F0; Mon, 03 Oct 2022 18:31:58 -0400 Original-Received: by mail-pg1-x530.google.com with SMTP id a23so3170205pgi.10; Mon, 03 Oct 2022 15:31:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date; bh=Ihsj6SI9KkgCqMfjxK0FniJigbibHeavUi+EFsWOcXc=; b=IExTYevjPmucEqooqp/sgDz5pWlWs1QFDRe6GaA3VNkh2GjTWyS5qvAuZ/9jImc82B DMsQm4t463l4YlUnFa3etR2waOfOmde1dRXiKacVMd7GyIU93oAdd9ImtyAjnv691CdA OQT+Cp7vBQz9e82NPBoImW+MNuB18DOURFKU5YEi8O35E2XG965qVUYmCraHUJGWcE+1 Rarx/tDtdGYBsdlYgidZQ8EggkD8Ji9/FjPtIzURjDiVZhTb4E6UlGqS63h8qwDUiWp8 lMnQab7fIgvfj7bbIRToulOsvsvVhs82uwCbXAYIi9uMTDBfZLT+CVawd86Epl3hg/U+ 0+jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=Ihsj6SI9KkgCqMfjxK0FniJigbibHeavUi+EFsWOcXc=; b=3t7K+sN+Qgahr0tBXeVCPFvnzxZrNf5FGW90fVtTTqdHfMpd+94ng1yKhQ4bRahAXX nMcvc3f5Mt/5qkpm0LX3ARoGrdofSsbpNLN2JQSePPMIx4v1PIN9Zt1UkK3s43CUETyq UabChcVziWi6xhTxvMDXEqYYwI2dZm9S3kAug4C0ePeZ14JRCUHyOjnu5qR1bTyHTuvD GIK9yuXVfmWP6ZH8qnPpvl1pS9g7+SqlAIBdbm2gOmREbEIQ2mP6VtGeZLbsedtOuY2g gxi2/boeabSkaL1QNbttJLe04foTlWlyfwgborJvkSkf1UEKH1Y1lIktoGTGwsAeOAts 6Ybg== X-Gm-Message-State: ACrzQf0eziguMbHEpchLsYIx4vPONixhASjmiG4gWL4MKwFFahArgAho Xoh4qNYqHojuVZ5y8+lOoRk= X-Google-Smtp-Source: AMsMyM7J5dTtUY9Izm/pWr2fexnZ++GmrbD+aiRWWF2M9tFkDlzKBsak4wipKDmM4F6UZJgbc9bRKQ== X-Received: by 2002:a05:6a00:a29:b0:54e:6aed:c655 with SMTP id p41-20020a056a000a2900b0054e6aedc655mr24371315pfh.25.1664836314912; Mon, 03 Oct 2022 15:31:54 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id 5-20020a170902c24500b0017de5165b60sm5043635plg.139.2022.10.03.15.31.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Oct 2022 15:31:54 -0700 (PDT) In-Reply-To: <87tu4klfcw.fsf@gmail.com> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=casouri@gmail.com; helo=mail-pg1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:296806 Archived-At: > On Oct 3, 2022, at 3:19 PM, Matthias Meulien = wrote: >=20 > Eli Zaretskii writes: >=20 >>> From: Matthias Meulien >>> Cc: emacs-devel >>> Date: Mon, 03 Oct 2022 20:07:44 +0200 >>>=20 >>> I also cloned tree-sitter-python but I've no idea of what should be = done >>> with the grammar file. I've understood that I am suppposed to = convert >>> the grammar to a shared object but I don't know how... >>>=20 >>> (I've tree-sitter-cli installed and in path, but "tree-sitter = generate >>> tree-sitter-python/grammar.js" seems to generate rust and node = bindings; >>> Am I supposed to compile the src/parser.c file? I don't see any >>> Makefile...). >>=20 >> Some of these lack the Makefile. But the Makefile is standard and = can >> be taken from any other language module, for example I see on in >> tree-sitter-ruby. So just clone that as well, copy its Makefile into >> tree-sitter-python, and run "make". >=20 > Thank you, Eli. It wasn't as easy as you said but I managed to = compile > a shared object using a modified version of the Makefile found in the > tree-sitter-ruby (using the file as is fails when building > tree-sitter-{ruby,python} due to a missing -Wl, before -soname usage). >=20 > At first sight, moving commands and imenu seems to work as > expected. Fontification too. I didn=E2=80=99t modify and move commands. There are a lot of them and I = don=E2=80=99t know if tree-sitter would bring any improvement. Imenu and = font-lock are indeed powered by tree-sitter. >=20 > I saw small differences between buffers fontified with > `python-use-tree-sitter' equal to nil and t. Attached is a screenshot > where one can see two such differences (the third tall buffer shows = the > output of "tree-sitter highlight"): >=20 > - line 284: The self attribute Why is the _url attribute highlighted? Other attributes don=E2=80=99t = seem to be highlighted. >=20 > - line 296: The variable in the f-string That is expected? I added that to add a bit of flair to tree-sitter = font-lock ;-) >=20 > > I'll keep using this branch and collect unexpected behaviors. Thanks! Yuan=