GNU bug report logs - #55428
[feature/tree-sitter] Simplify the parser creation API

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Daniel Martín <mardani29@HIDDEN>; dated Sun, 15 May 2022 14:17:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 55428 <at> debbugs.gnu.org:


Received: (at 55428) by debbugs.gnu.org; 15 May 2022 14:26:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 15 10:26:31 2022
Received: from localhost ([127.0.0.1]:50375 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nqFCZ-0006Y1-ER
	for submit <at> debbugs.gnu.org; Sun, 15 May 2022 10:26:31 -0400
Received: from eggs.gnu.org ([209.51.188.92]:43236)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1nqFCX-0006Xl-Qm
 for 55428 <at> debbugs.gnu.org; Sun, 15 May 2022 10:26:30 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:47936)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1nqFCS-0005bp-JQ; Sun, 15 May 2022 10:26:24 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=UKy7eeV+mBNp0+diUdSIdMYWMk3/Nvflm98w/C9CAog=; b=GXQ63VI/S71jaku+J6yn
 e4IMPsqCVujLcaFJucT4YPzy5J6y83KF24HLvfiJ7Q4tQFjb9UpCAzBJak5U4zRu6z6wknsSNqFfP
 NxtIxDn2c890rdGFO/wiwvDxS+q/E7KLfkuJhZeSp1VzUSmr3mxF37CdWaWdGy/BjLf5TmI4RxEf7
 At1vxTFugxeAcyPGBj5EkyatJ+fcNGpnERybZ1YUOb8TzYqpuS5vUAlFeZCCPpmw4DsOm8qBtHJE+
 M4pE1BWluVztnz9K48yQhuRDpkDiA15dDPUaTZq/JfXPWY6JmJlAChjlvli2Q+vAnS5ho5uP/5qez
 ZYU/JdSE9vf0JQ==;
Received: from [87.69.77.57] (port=3882 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1nqFCR-0005kg-WC; Sun, 15 May 2022 10:26:24 -0400
Date: Sun, 15 May 2022 17:26:11 +0300
Message-Id: <83h75qkh31.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Daniel =?utf-8?Q?Mart=C3=ADn?= <mardani29@HIDDEN>
In-Reply-To: <m1wnem990i.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#55428: [feature/tree-sitter] Simplify the parser creation API
References: <m1wnem990i.fsf.ref@HIDDEN> <m1wnem990i.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 55428
Cc: 55428 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Sun, 15 May 2022 16:15:57 +0200
> From:  Daniel Martín via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> 
> Currently, there are three functions to create a tree-sitter parser:
> 
> - treesit-get-parser-create
> - treesit-get-parser
> - treesit-parser-create
> 
> I think this set of similarly named functions can be reduced, so that
> developers don't need to remember a lot of APIs.  How I understand the
> problem of creating a tree-sitter parser is that we need three things
> from the developer:
> 
> - A programming language (a symbol).
> - A buffer (optional, default to the current buffer).
> - Whether to create or reuse an existing parser for that language.
> 
> I think it would be simpler to have just one parser creation API like
> 
> (treesit-make-parser LANGUAGE &optional BUFFER ALWAYS-NEW)

I suggest that discussions about the API be held on emacs-devel, not
hear.  That way, more people will see them and could decide whether to
participate.

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#55428; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 15 May 2022 14:16:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 15 10:16:21 2022
Received: from localhost ([127.0.0.1]:50354 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nqF2c-0006Hv-WA
	for submit <at> debbugs.gnu.org; Sun, 15 May 2022 10:16:20 -0400
Received: from lists.gnu.org ([209.51.188.17]:34514)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mardani29@HIDDEN>) id 1nqF2b-0006Hn-7k
 for submit <at> debbugs.gnu.org; Sun, 15 May 2022 10:16:13 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:34998)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mardani29@HIDDEN>)
 id 1nqF2a-0005Zw-Cv
 for bug-gnu-emacs@HIDDEN; Sun, 15 May 2022 10:16:13 -0400
Received: from sonic305-20.consmr.mail.ir2.yahoo.com ([77.238.177.82]:41521)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <mardani29@HIDDEN>)
 id 1nqF2X-00035B-HB
 for bug-gnu-emacs@HIDDEN; Sun, 15 May 2022 10:16:11 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048;
 t=1652624164; bh=hF+aBCWh1wmU7WnqTckisao0LYOwR+PXusTUfISC+9w=;
 h=From:To:Subject:Date:References:From:Subject:Reply-To;
 b=pIiyJf/dYjiCZV0wF6NG8hig4CZCAXFFFNXemAndNia3JgNS8INp0Dwg2h6y/XTl6z1+D8O+aezVvTy/LXMUthGCAlXOLjAWpX7h4Wmb15IPljZck5foZOCxvCusj1by4y8zdGPRZn4Fjut4zxdqzTFFFEe2LNC3t6cQIc5B8Rgp5RVV1I85IcRysFMs/g5N4Bn1Ht0fLMxp3x3o195ybei0na2tAOnNgP7Cj0tIOJSNw73dCX8T7W+D0bOlQ7L7HMzSIepLCrKitMhIzsXVID//z5nJFwJXjkdn4vZxd+7emaftlhPMvvuxOaVWFbMRiz2blU6iM8V/3MH984sA3A==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1652624164; bh=Wsu4nfFd3UBTvReZysg9w8mGFKoP5/SMJiW6WZ7njdX=;
 h=X-Sonic-MF:From:To:Subject:Date:From:Subject;
 b=kdT4Rl7JD9Su0eu9VAMdOtwTIJ1SsyQw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4ncEUtp2bqVp6406Cu91Q
 4vw8m9L0sUe98uQFKDr6oORM1CneuZVdJLGZgVGBoI9sh0iYnTvW_LTeQfHOcTf.e5TU7W9zNw9f
 svTiw9eUT00qTvXI5BE_96d5AIDbvYYCp_eFDFj9xuKYU1dCvdSzxFxkyeEr3ioc2VC_29f2iHuX
 XtO4bdd.swTv9FONUhw2J5Q2GKfDxI5NOehhDRYUGzVQ7qT6EKEULQOAxRE0FhUSR7E23uRHjvfr
 xGp5a1BBylqitePra5diiybptpEH3WkOUMkYKNWUQWWxncU5NX6z9DiU52nKyxyMlvtgrk6Q.v7J
 SQW1HsIH6ekm2_getUl5Mzipqdwjf1RG8mPj6.d38F8XyDsXNAtExefRWD5mPwJODnWW6P3txXla
 O1sGUB8lvx1waX4aHvBVy1f7BBCQnxumjPcVsT6c57ewUUUV2ETAF.YO96UITvn.6HgGJzXtotLZ
 BxOfjrSXiQYcKWfFv3UE7QQjflYUEjZ4Codg2
X-Sonic-MF: <mardani29@HIDDEN>
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic305.consmr.mail.ir2.yahoo.com with HTTP; Sun, 15 May 2022 14:16:04 +0000
Received: by hermes--canary-production-ir2-695448f88c-ksb2v (Yahoo Inc. Hermes
 SMTP Server) with ESMTPA ID 98ad6d6cce8f8a2b4d7917b331551566; 
 Sun, 15 May 2022 14:15:58 +0000 (UTC)
From: =?utf-8?Q?Daniel_Mart=C3=ADn?= <mardani29@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [feature/tree-sitter] Simplify the parser creation API
Date: Sun, 15 May 2022 16:15:57 +0200
Message-ID: <m1wnem990i.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
References: <m1wnem990i.fsf.ref@HIDDEN>
X-Mailer: WebService/1.1.20188
 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo
Content-Length: 991
Received-SPF: pass client-ip=77.238.177.82; envelope-from=mardani29@HIDDEN;
 helo=sonic305-20.consmr.mail.ir2.yahoo.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)


Currently, there are three functions to create a tree-sitter parser:

- treesit-get-parser-create
- treesit-get-parser
- treesit-parser-create

I think this set of similarly named functions can be reduced, so that
developers don't need to remember a lot of APIs.  How I understand the
problem of creating a tree-sitter parser is that we need three things
from the developer:

- A programming language (a symbol).
- A buffer (optional, default to the current buffer).
- Whether to create or reuse an existing parser for that language.

I think it would be simpler to have just one parser creation API like

(treesit-make-parser LANGUAGE &optional BUFFER ALWAYS-NEW)

There are similar API patterns like this one already in Emacs.  With
this proposed API, the common case, which is to create a parser for the
current buffer, and to try to reuse one if it already exists, is very
simple from the POV of an ELisp developer integrating with tree-sitter:

(treesit-make-parser 'c)

Any thoughts?




Acknowledgement sent to Daniel Martín <mardani29@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#55428; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 17 Jun 2022 09:45:02 UTC

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