From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Fu Yuan Newsgroups: gmane.emacs.devel Subject: Tree-sitter api (Was: Re: How to add pseudo vector types) Date: Sat, 7 Aug 2021 00:31:36 -0500 Message-ID: <95F37923-5BF9-4D81-B361-267CF119FBCA@gmail.com> References: <83r1f7hydn.fsf@gnu.org> Mime-Version: 1.0 (1.0) 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="29949"; mail-complaints-to="usenet@ciao.gmane.io" Cc: cpitclaudel@gmail.com, stephen_leake@stephe-leake.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 07 07:32:28 2021 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 1mCEwe-0007b8-Dz for ged-emacs-devel@m.gmane-mx.org; Sat, 07 Aug 2021 07:32:28 +0200 Original-Received: from localhost ([::1]:42818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCEwc-0003pd-Ae for ged-emacs-devel@m.gmane-mx.org; Sat, 07 Aug 2021 01:32:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCEvt-0003AF-JQ for emacs-devel@gnu.org; Sat, 07 Aug 2021 01:31:41 -0400 Original-Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]:39749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mCEvs-0008UZ-5X; Sat, 07 Aug 2021 01:31:41 -0400 Original-Received: by mail-io1-xd29.google.com with SMTP id r72so1958409iod.6; Fri, 06 Aug 2021 22:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=4u1qCLMkdEFAJi0wtUq47wRW5NJKbrrGwG1K9jNP2hI=; b=c0rn6dRvmGkPIxlE/QIRIk3wifD+DPMJIAm8wTeWRBVe6uRM8JbeNQmTRBWds5WR8x p+mbqf1ZvV0GqVn13rWKoczZkd07RikJ8za4PAf+ac9Rk3SCp8bJK9VKMRnPxIRrzMOT qNyfzRfw2XsD+dEOTGTDnLCZ94cWCnjTbe/g2WTmb9ptnYx3Hgaaounw/xQ+UkEVGfB5 WupmkFUdB9QdTaCEzPkHKsj/v3Vp6OvvFpzlQcWTXxtJkihriwjMf57mIrMFzHFZ+7OQ 8ZLY7f2soP13/OiUfP31IpiqF7cuzwJ4Se2daTueItnS3wZtlhqXbK/FMUJAQ0gz+d1Y nUtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=4u1qCLMkdEFAJi0wtUq47wRW5NJKbrrGwG1K9jNP2hI=; b=GXxIcHVJzQMxXiym95B7i8mTBD84r5pfnNn54PSFARTSwssYrn5WxoXr5yOLOtAs6v utCXTu8gmxfYV4NoOmIM5SeOTmqGzlQ77dMNPyJxYtK1NKhauNMPH1rRQXIpyerdaz/V LUkRZC7LiWueryBSQe7u8OwPi/VYKVYkeTXPC/geVM74eAsCWhPfphIdO1zPXWdT2ZTa rjkHIfkgjURLBG8rmUwaoefQJUfK/tlQZiCBcHfOqy2m4rZ4n2ykoQE2PJa3wh/FpaUw BkJYF31a6p/7AF2/5COJ1+x2F1KnAoz5UEyPsUMEVRt9OL25jDUu0qBRRme9JVpYY8yZ bp3w== X-Gm-Message-State: AOAM530jDtdt5lXOWjrWSZhMphuhl7kbli9k4/No9Zv8GBAaXlKFlOic NGExa+tshfvA8vZYoj2GDNM= X-Google-Smtp-Source: ABdhPJwNsB6D0Nw7+k1Vz6QcpHKRTAYWnaEFoEcyRKX9M8Y7rzlFRTNZEmU9RHzJhoUhL1d1brNitA== X-Received: by 2002:a5e:aa06:: with SMTP id s6mr86529ioe.61.1628314298111; Fri, 06 Aug 2021 22:31:38 -0700 (PDT) Original-Received: from ?IPv6:2607:fb90:17dd:eaca:951e:7f07:ffb7:336b? ([2607:fb90:17dd:eaca:951e:7f07:ffb7:336b]) by smtp.gmail.com with ESMTPSA id j6sm3216470iom.5.2021.08.06.22.31.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Aug 2021 22:31:37 -0700 (PDT) In-Reply-To: <83r1f7hydn.fsf@gnu.org> X-Mailer: iPhone Mail (17H35) Received-SPF: pass client-ip=2607:f8b0:4864:20::d29; envelope-from=casouri@gmail.com; helo=mail-io1-xd29.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:272156 Archived-At: > =E5=9C=A8 2021=E5=B9=B48=E6=9C=886=E6=97=A5=EF=BC=8C=E4=B8=8A=E5=8D=881:37= =EF=BC=8CEli Zaretskii =E5=86=99=E9=81=93=EF=BC=9A >=20 > =EF=BB=BF >>=20 >> From: Yuan Fu >> Date: Thu, 5 Aug 2021 23:22:17 -0400 >> Cc: cpitclaudel@gmail.com, stephen_leake@stephe-leake.org, >> Stefan Monnier , emacs-devel@gnu.org >>=20 >> I=E2=80=99ve added bindings for set_ranges and pushed the latest code to h= ttps://github.com/casouri/emacs/tree/ts >>=20 >> As for now, I=E2=80=99ve created bindings for most of the functions I wan= t to expose. Next I=E2=80=99ll probably write some more tests (in addition t= o responding reviews and comments). >=20 > Thanks. >=20 > We should probably start thinking how to integrate TS-related > functionalities into Emacs in general. E.g., should there be an > option to activate it? should this option be per major mode? something > else? We should have a user option to control tree-sitter on major mode level. May= be an alist where each car is a major node symbol and each cdr is a Boolean v= alue toggling tree-sitter for that node. We also need tree-sitter-maximum-buffer-size, so that buffer larger than thi= s size won=E2=80=99t enable tree-sitter. (And we need to make sure we never u= se tree-sitter on buffers larger than 4GB because tree-sitter uses unint32.)= And we can provide a function free-sitter-should-activate-p that computes if= we should enable tree-sitter in the current buffer by variables mentioned a= bove, that can be used by major-modes when setting up. I=E2=80=99m also thinking about having a tree-sitter-defaults that=E2=80=99s= analogous to font-lock-defaults, that is set by each major node and used to= generate tree-sitter-font-lock-settings. As for indentation, we could provide some infrastructure like we do for font= -locking, or we can just let major modes implement their indent function wit= h tree-sitter api. Yuan=