From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#71086: 30.0.50; Setting treesit-indent-function is not effective is treesit-simple-indent-rules is nil Date: Tue, 21 May 2024 14:43:34 +0300 Message-ID: <86pltf8k61.fsf@gnu.org> References: <87y184q7ai.fsf@telefonica.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35473"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71086@debbugs.gnu.org To: =?UTF-8?Q?=C3=93scar?= Fuentes , Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 21 13:44:15 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1s9Nug-00090A-J6 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 May 2024 13:44:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9NuQ-0001ZB-GM; Tue, 21 May 2024 07:43:58 -0400 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 1s9NuP-0001XQ-26 for bug-gnu-emacs@gnu.org; Tue, 21 May 2024 07:43:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9NuO-0000ne-QJ for bug-gnu-emacs@gnu.org; Tue, 21 May 2024 07:43:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s9NuT-00021d-UG for bug-gnu-emacs@gnu.org; Tue, 21 May 2024 07:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 May 2024 11:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71086 X-GNU-PR-Package: emacs Original-Received: via spool by 71086-submit@debbugs.gnu.org id=B71086.17162918297772 (code B ref 71086); Tue, 21 May 2024 11:44:01 +0000 Original-Received: (at 71086) by debbugs.gnu.org; 21 May 2024 11:43:49 +0000 Original-Received: from localhost ([127.0.0.1]:48721 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9NuH-00021I-Fs for submit@debbugs.gnu.org; Tue, 21 May 2024 07:43:49 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9NuG-00021C-06 for 71086@debbugs.gnu.org; Tue, 21 May 2024 07:43:48 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9Nu4-0000km-Se; Tue, 21 May 2024 07:43:36 -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=0V2Tzq9P5GXkHIZQR5X0Fi5GBQWFeMdyAdPl1Rb9iHU=; b=hB4dCh/1Wa/zY21WY05k 43r6Vn0/5Mg0DamNV2Xjb5ukBOQGazQcFiKqYXaHFbJ8EyT03Jj/Gpcmup8LulGSn4kl9zSiXAaiF MT8TkkGQGimvoxMeuarcA/4kJxzvtQWDsDffQ+HOx252PauMkIPcp/a25bean2u3JmYbzw0XXtrKu 9NMYHxuCrJYGNQwiq3O6DMBaG2f2aqwdSkSJCdd9BhheQrWd2R+9Q1PmoG3NE3wNMT9PBgyQQMQz+ 7PwQoUj0LLonEjJm+jyKA1hEYpan7676hwr5wVOvLJ4on5sa0ZFGxdCEBBpgK8h9bMa2iRDhAgIBq LEHfEvNPAb1yUQ==; In-Reply-To: <87y184q7ai.fsf@telefonica.net> (message from =?UTF-8?Q?=C3=93scar?= Fuentes on Tue, 21 May 2024 03:32:05 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:285529 Archived-At: > From: Óscar Fuentes > Date: Tue, 21 May 2024 03:32:05 +0200 > > > treesit-major-mode-setup setups indentation if and only if > treesit-simple-indent-rules is non-nil. So the major mode author is > forced to set that variable even when he makes no use of the > treesit-simple-indent facilities and instead sets > treesit-indent-function to his own function. If your mode defines a treesit-indent-function, why do you need the help of treesit-major-mode-setup for setting up indentation? The idea of treesit-simple-indent, AFAIU, is to automate the simple cases, on the assumption that the mode complex cases cannot be second-guessed up front, and the mode programmer will need to set that up manually. For example, you can assign your functions to indent-line-function and indent-region-function. Or what am I missing? > OTOH, the info node for "Parser-based Indentation" says: > > To enable the parser-based indentation engine, either set > ‘treesit-simple-indent-rules’ and call ‘treesit-major-mode-setup’, or > equivalently, set the value of ‘indent-line-function’ to > ‘treesit-indent’. > > However, treesit-major-mode-setup does more than what's described after > "equivalently": > > (when treesit-simple-indent-rules > (setq-local treesit-simple-indent-rules > (treesit--indent-rules-optimize > treesit-simple-indent-rules)) > (setq-local indent-line-function #'treesit-indent) > (setq-local indent-region-function #'treesit-indent-region)) So this is just a matter of updating the documentation to mention indent-region-function? I've added Yuan, in case he has comments or suggestions.