From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jostein_Kj=c3=b8nigsen?= Newsgroups: gmane.emacs.devel Subject: Re: Detecting tree-sitter based major-modes for end-user customization and third party functions/packages Date: Tue, 20 Dec 2022 21:14:03 +0100 Message-ID: References: <6c5b1d81-b6ce-bc87-f58e-c950b57fd20b@secure.kjonigsen.net> <2d22346c-cc6e-223a-dff3-140188291914@secure.kjonigsen.net> Reply-To: jostein@kjonigsen.net Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------yuz5zSx2rU7QnVGNIo00bYSX" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35815"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Cc: jostein@kjonigsen.net, "Ergus via Emacs development discussions." , Yuan Fu , Theodor Thornhill To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 20 21:14:35 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 1p7j0T-000939-Ld for ged-emacs-devel@m.gmane-mx.org; Tue, 20 Dec 2022 21:14:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7j08-0006qZ-Q6; Tue, 20 Dec 2022 15:14:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7j07-0006px-FF for emacs-devel@gnu.org; Tue, 20 Dec 2022 15:14:11 -0500 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7j04-00031C-Nl for emacs-devel@gnu.org; Tue, 20 Dec 2022 15:14:10 -0500 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 84BCD320096B; Tue, 20 Dec 2022 15:14:06 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 20 Dec 2022 15:14:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= secure.kjonigsen.net; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:sender:subject:subject:to:to; s=fm1; t= 1671567246; x=1671653646; bh=76wxMp0TjFI0xVbGg5YNOkiQl9z+5qcejWa f2x3pjNk=; b=CpdIY11ku/yOz3SsBTdvOfxxtXA+vEKSmsUJQxgFv9y+3GrpLQt b6FvW6diVRski3JFTqZVBK4gy3+ZgpEktcn/jz6lC8MDwJ1Q3Owb9CduAfSMoMde RM2nuIizf0vxIsBG2dXb6WM9Qtkohm55DZk0fxUZFiWlNFMJviol3gAmsYyVsi3Q xVa/Pn6z65q6DS2EPiapgRf2Wj4ceunA5TQgoaC5IJSj96Be5+k6jvK5x6SJIRKn AkEfDqKYweFAETraKAgbMbwxUri0xpTzP0jWrYQGjbYCyjQtbztcGwOQ5Yq816Jz RN7WnGVe1Tiicf35HNlNr5HV5SR9zVdDdvg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1671567246; x=1671653646; bh=76wxMp0TjFI0x VbGg5YNOkiQl9z+5qcejWaf2x3pjNk=; b=kUyT50Ldbj9WExo57qtS0IAZ73YRV 9UEUvbBQe/RK3b1VocPCIQq2q4lILt13Zhiln7DID7xWlxnrdq3rJX/RoFZ+8NUv RUgaQCjFRkWt08hQNCFy/7Z8OAInRe36jsSKRe2cAq7nayuHr0el/jo9S7+cWnh8 G2y7+sACKdSJnKEzTnN+QFXxoVDbbRvKESdIRhMBFweugfnQowGvn/wJKspspiXJ /ve87N3wdx3hV2MA+ogICX7UCwK+LofMhn7tc5UqMCzWk/osYsRJBvT8Z6xnzQRZ t4KpUDZHs3wCFLoUvWMs39gfwLPXo7ewLsgPsRqkLl0c7fUzWs74q0lmQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeeigddutdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurheptgfkffggfghruffvvehfhfgjsegrtderredtfeejnecuhfhrohhmpeflohhs thgvihhnucfmjhppnhhighhsvghnuceojhhoshhtvghinhesshgvtghurhgvrdhkjhhonh highhsvghnrdhnvghtqeenucggtffrrghtthgvrhhnpeeujeejteehhfefgffftefghefg geeigeegtddvjeetjeejgedvueejhffgueefgeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehjohhsthgvihhnsehsvggtuhhrvgdrkhhjohhn ihhgshgvnhdrnhgvth X-ME-Proxy: Feedback-ID: ib2f84088:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Dec 2022 15:14:05 -0500 (EST) Content-Language: en-GB, nb-NO In-Reply-To: Received-SPF: pass client-ip=64.147.123.20; envelope-from=jostein@secure.kjonigsen.net; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, NICE_REPLY_A=-1.161, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:301704 Archived-At: This is a multi-part message in MIME format. --------------yuz5zSx2rU7QnVGNIo00bYSX Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 20.12.2022 21:03, Stefan Monnier wrote: >>> (treesit-parser-list) seems like a good first approximation, tho I guess >>> it depends exactly what they want to do with that info. >> That name isn't very intuitive for what it does, > AFAIK what it does is return a list of parsers currently setup in the > buffer, so its name seems very intuitive. > > Maybe you're thinking of using it for some other purpose? > If so, please describe which one. > > > Stefan > At this point treesitter is new, and I'm interested in investigating its general capabilities outside of specific major-modes. Take for instance the ability to paredit-like navigate up the current parse-tree, regardless of major-mode, as long as it uses tree-sitter. Something like the code below: (defun my-auto-parent ()   (interactive)   (when (treesit-parser-list)     (goto-char (treesit-node-start (treesit-node-parent (treesit-node-at (point))))))) Basically I just want a true or false check for if I'll be able to move on to using treesit-* functionality, or possibly using that specifically in my hooks to replace "primitive" functions and bindings with tree-aware functions instead. Like I said, (treesit-parser-list) does indeed work, but in a case like this where you don't really care about /what/ parser is being used, only that -a- parser is being used, a simpler, more appropriately named function might be beneficial. Just my 2 cents. -- Jostein --------------yuz5zSx2rU7QnVGNIo00bYSX Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit On 20.12.2022 21:03, Stefan Monnier wrote:
(treesit-parser-list) seems like a good first approximation, tho I guess
it depends exactly what they want to do with that info.
That name isn't very intuitive for what it does,
AFAIK what it does is return a list of parsers currently setup in the
buffer, so its name seems very intuitive.

Maybe you're thinking of using it for some other purpose?
If so, please describe which one.


        Stefan

At this point treesitter is new, and I'm interested in investigating its general capabilities outside of specific major-modes.

Take for instance the ability to paredit-like navigate up the current parse-tree, regardless of major-mode, as long as it uses tree-sitter.

Something like the code below:

(defun my-auto-parent ()
  (interactive)
  (when (treesit-parser-list)
    (goto-char (treesit-node-start (treesit-node-parent (treesit-node-at (point)))))))

Basically I just want a true or false check for if I'll be able to move on to using treesit-* functionality, or possibly using that specifically in my hooks to replace "primitive" functions and bindings with tree-aware functions instead.

Like I said, (treesit-parser-list) does indeed work, but in a case like this where you don't really care about what parser is being used, only that -a- parser is being used, a simpler, more appropriately named function might be beneficial.

Just my 2 cents.

--
Jostein

--------------yuz5zSx2rU7QnVGNIo00bYSX--