From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: master 09b5f00613: ; Fix calls to treesit functions Date: Mon, 19 Dec 2022 15:51:22 +0100 Message-ID: <878rj378gl.fsf@thornhill.no> References: <167138365421.15060.2886694741391315956@vcs2.savannah.gnu.org> <20221218171414.77B8EC0060F@vcs2.savannah.gnu.org> <831qowf54k.fsf@gnu.org> <83sfhbefuu.fsf@gnu.org> <87bknz7bf7.fsf@thornhill.no> <837cyne9tb.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36128"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 19 15:52:23 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 1p7HV7-000937-Ti for ged-emacs-devel@m.gmane-mx.org; Mon, 19 Dec 2022 15:52:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7HUI-0002zO-RH; Mon, 19 Dec 2022 09:51:30 -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 1p7HUH-0002zF-Hc for emacs-devel@gnu.org; Mon, 19 Dec 2022 09:51:29 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7HUE-00057f-UG; Mon, 19 Dec 2022 09:51:29 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1671461484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZEdCWWyKm8HnwdLaoI5fyA22mEzycK2aaPrj8YNZ2GQ=; b=umZdgBwfeERAoZP3p1J7gF3hZayj6y8SFVGcIcwEn/gKO9GzJ/gJIrHHYykgy9RIfReE2f K0GgSeKrOI/d0jyaRzOSxD+aRYk+F7OTnUqxp6m0eJ0BiuuDAqxeE2c09W6YEjHHtxps6B wC19BceV7l56j9tpiuRHdF6MSra/iCg5V0hOXGwZAA/i9el9IPPs3wdSsGcGd62Y9UbPXa 1loZHbvRS4ArI7dRhhWHFrK7wbZ7JITjJtlsye0nG4Tk5XO9vOtT3GU9k1tKLz2SWr3vzv X8cRMLSOkHyX8g5CPsv3/zV/lSYmJOJkLLDgTkY+dI256WdvbQ/sbyhgOxq7Bg== In-Reply-To: <837cyne9tb.fsf@gnu.org> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=188.165.223.204; envelope-from=theo@thornhill.no; helo=out2.migadu.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, 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:301646 Archived-At: Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: emacs-devel@gnu.org, monnier@iro.umontreal.ca >> Date: Mon, 19 Dec 2022 14:47:24 +0100 >> >> Eli Zaretskii writes: >> >> >> Date: Mon, 19 Dec 2022 07:26:35 +0100 >> >> From: Theodor Thornhill >> >> >> >> How about treesit-ensure, that checks treesit-available-p and whether it's enabled for the current mode? The treesit-parser-list is also kind of working just by accident, as it isn't its job to ensure availability. >> > >> > Isn't that what treesit-language-available-p already does? >> >> Yeah, but I don't want to check for a particular language, only that >> subsequent calls to treesit-functions will be available. > > You said: > > How about treesit-ensure, that checks treesit-available-p and > whether it's enabled for the current mode? > > If this check is for the current mode, then you already have the > "particular language", don't you? > > And that is eventually the right test, because even if the tree-sitter > library is compiled in and available, the grammar library might not > be, which means the code cannot use tree-sitter in such a situation. Yeah, but in for example prog-mode I then have to do something like (treesit-language-available-p (treesit-language-at (point))) Which seems long. IIRC I used something similar in an earlier patch, and was dismissed because it should have its own api? ``` (interactive "P") (save-excursion (if (or (and (treesit-available-p) (treesit-ready-p (treesit-language-at (point))) (string-match-p treesit-comment-type-regexp ``` >>> For example, \"(line|block)_comment\". ") >> The intent is that major modes set this variable? SGTM. > (if (or (and (treesit-available-p) > (treesit-ready-p (treesit-language-at (point))) >> I'd imagine that this kind of test should have an API, so the >> treesit-ready-p call should not be made explicitly? Yuan, WDYT? >> Also, isn't it enough to check whether the buffer has a tree-sitter >> parser or something? Theo