From unknown Mon Aug 18 19:27:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#71086: 30.0.50; Setting treesit-indent-function is not effective is treesit-simple-indent-rules is nil Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 May 2024 01:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71086 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 71086@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.171625515620155 (code B ref -1); Tue, 21 May 2024 01:33:02 +0000 Received: (at submit) by debbugs.gnu.org; 21 May 2024 01:32:36 +0000 Received: from localhost ([127.0.0.1]:46082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9EMm-0005F1-Dp for submit@debbugs.gnu.org; Mon, 20 May 2024 21:32:36 -0400 Received: from lists.gnu.org ([209.51.188.17]:34162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9EMj-0005Ev-Td for submit@debbugs.gnu.org; Mon, 20 May 2024 21:32:35 -0400 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 1s9EMe-0003IB-LO for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 21:32:28 -0400 Received: from relayout01-redir.e.movistar.es ([86.109.101.201]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9EMa-0005V6-Rj for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 21:32:28 -0400 Received: from sky (81.red-81-39-130.dynamicip.rima-tde.net [81.39.130.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout01.e.movistar.es (Postfix) with ESMTPSA id 4VjxkG3X9HzfcbT for ; Tue, 21 May 2024 03:32:06 +0200 (CEST) From: =?UTF-8?Q?=C3=93scar?= Fuentes Date: Tue, 21 May 2024 03:32:05 +0200 Message-ID: <87y184q7ai.fsf@telefonica.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-TnetOut-Country: IP: 81.39.130.81 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout01 X-TnetOut-MsgID: 4VjxkG3X9HzfcbT.AAD46 X-TnetOut-SpamCheck: no es spam, clean X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1716859926.80434@gpSdY53wPHO5hCm13SlNLA X-Spam-Status: No Received-SPF: softfail client-ip=86.109.101.201; envelope-from=ofv@wanadoo.es; helo=relayout01-redir.e.movistar.es 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) 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. Having to assign a dummy value to a variable that belongs to an API that is not used is surprising. Furthermore, it is unspecified what kind of values are acceptable on that scenario. I would expect that treesit-major-mode-setup shall setup indentation when treesit-indent-function is non-nil. OTOH, the info node for "Parser-based Indentation" says: To enable the parser-based indentation engine, either set =E2=80=98treesit-simple-indent-rules=E2=80=99 and call =E2=80=98treesit-m= ajor-mode-setup=E2=80=99, or equivalently, set the value of =E2=80=98indent-line-function=E2=80=99 to =E2=80=98treesit-indent=E2=80=99. 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)) In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.0) of 2024-05-19 built on sky Repository revision: 98b83bdc9f4af7798e3314ad8df6ab78efd60f8a Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101011 System Description: Debian GNU/Linux trixie/sid Configured using: 'configure --with-native-compilation --without-toolkit-scroll-bars --with-x-toolkit=3Dlucid --with-modules --without-imagemagick' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBOTF LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TREE_SITTER WEBP X11 XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: C locale-coding-system: nil From unknown Mon Aug 18 19:27:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#71086: 30.0.50; Setting treesit-indent-function is not effective is treesit-simple-indent-rules is nil 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 X-GNU-PR-Keywords: To: =?UTF-8?Q?=C3=93scar?= Fuentes , Yuan Fu Cc: 71086@debbugs.gnu.org Received: via spool by 71086-submit@debbugs.gnu.org id=B71086.17162918297772 (code B ref 71086); Tue, 21 May 2024 11:44:01 +0000 Received: (at 71086) by debbugs.gnu.org; 21 May 2024 11:43:49 +0000 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 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 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==; Date: Tue, 21 May 2024 14:43:34 +0300 Message-Id: <86pltf8k61.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87y184q7ai.fsf@telefonica.net> (message from =?UTF-8?Q?=C3=93scar?= Fuentes on Tue, 21 May 2024 03:32:05 +0200) References: <87y184q7ai.fsf@telefonica.net> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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. From unknown Mon Aug 18 19:27:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#71086: 30.0.50; Setting treesit-indent-function is not effective is treesit-simple-indent-rules is nil Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 22 May 2024 06:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71086 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: =?UTF-8?Q?=C3=93scar?= Fuentes , 71086@debbugs.gnu.org Received: via spool by 71086-submit@debbugs.gnu.org id=B71086.171635910025740 (code B ref 71086); Wed, 22 May 2024 06:25:02 +0000 Received: (at 71086) by debbugs.gnu.org; 22 May 2024 06:25:00 +0000 Received: from localhost ([127.0.0.1]:53736 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9fPH-0006h5-QA for submit@debbugs.gnu.org; Wed, 22 May 2024 02:25:00 -0400 Received: from mail-pl1-f170.google.com ([209.85.214.170]:53738) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9fPC-0006ge-Bt for 71086@debbugs.gnu.org; Wed, 22 May 2024 02:24:56 -0400 Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1edfc57ac0cso7250035ad.3 for <71086@debbugs.gnu.org>; Tue, 21 May 2024 23:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716359023; x=1716963823; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2BcOqzmYyG6jxovpq+C/JJ/U32+Tf8fXPunmljIHLIY=; b=DZuzD6gFsMqxuKmAhmUdUx8itvq6rY2QMbiBBBWWH2GQPDYVqwsdiwWWzbSaRTJOL7 3Kw/AGIP2De922gsXS8vMlHS3r2ic8QZAaH0GFyt6i4qg3cwrWwV/UweQXuaV/dfAdXV mUKAcdbR0R4O1P07wBJo7AvRxzjss/j98IRMsTl6T7ado/pwjfVXHx/eSC+59HHfBVqI YxvOzQY31ElPFDajk3J/xgLUTGUZW28s7VL4525lVKmX3FpHK7aOG7jGvRT1vcBlKBOw pGjFI7EtIC/I8ZTnc+5/MSL52N5fVEAvDRQjyU02dA1NCoskRo9dMMXV10XgS/wSy2gW 2Tbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716359023; x=1716963823; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2BcOqzmYyG6jxovpq+C/JJ/U32+Tf8fXPunmljIHLIY=; b=O+YZUuQMDQAKjD68iKYwZ2dSrtxfrXt5ffZuONVuE/l0XKDqS3qkAVuW/NpRlR1WYK EK/p7fxuTxfeokdjvvNhLcq9O6jUID5OFAR11ldxckeC+2eLlqOlAFJicApVGEVQiYAt UOUgC6kRR0GNswcLRBAOfHqa+ks2Vz3BRJSEoSfH6dkVyxticXg/7oK7IE9Pim6Jwgka h5cEUlNDl3Znll1QAiWhRwW1BEzTfBYMSs9TqPpRZrD4PuHdgBLaMuR9aaMPzvjA/Nv+ MwsSNou7m4wLF6056jvb5vH+FouXSS/Mb7ZZHX3IsY5c2KI/1pHwdHhqPXsvXzmeQOqj gaWg== X-Forwarded-Encrypted: i=1; AJvYcCVqARGF5yltzxJWMacYraFnhxaEZ8OzeQk485k040PdRV3vJPCJL7OHfTVMS/G/3B+P8hMpMvJ76gzjcLlSatDthS3f5Vw= X-Gm-Message-State: AOJu0Yy+MMYPGKEzW3zvvrBZS8BhoXpBQNN5xVX9Fv80WJFFgdQm+WSf dmhdcFGmnK5DJ2+inMDH6iEySBiGzYte6Cquvma97303R1ZT5Nlh X-Google-Smtp-Source: AGHT+IG3r7su9G85iHXH6KRGZ0avvrBIyZnn99DENBU/aP7/fb37ZG8t2ybuMrrlQeJFUE4bZ68z9w== X-Received: by 2002:a17:902:784e:b0:1eb:3daf:ebaf with SMTP id d9443c01a7336-1f31ca367b3mr9123025ad.57.1716359022626; Tue, 21 May 2024 23:23:42 -0700 (PDT) Received: from smtpclient.apple ([2601:641:300:4910:d47e:183a:1bb4:b282]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f30aeb3669sm29184975ad.182.2024.05.21.23.23.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2024 23:23:42 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.1\)) From: Yuan Fu In-Reply-To: <86pltf8k61.fsf@gnu.org> Date: Tue, 21 May 2024 23:23:30 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <87y184q7ai.fsf@telefonica.net> <86pltf8k61.fsf@gnu.org> X-Mailer: Apple Mail (2.3731.700.6.1.1) X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On May 21, 2024, at 4:43 AM, Eli Zaretskii wrote: >=20 >> From: =C3=93scar Fuentes >> Date: Tue, 21 May 2024 03:32:05 +0200 >>=20 >>=20 >> 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. >=20 > If your mode defines a treesit-indent-function, why do you need the > help of treesit-major-mode-setup for setting up indentation? >=20 > 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? There are actually another level of customization between setting = treesit-simple-indent-rules and setting indent-line-function, which is = setting treesit-indent-function. IIUC =C3=93scar is trying to do that = but found out treesit-major-mode-setup doesn=E2=80=99t automatically = setup indent-line-functions when treesit-indent-function is set. I=E2=80=99= ve now fixed that. (Though I didn=E2=80=99t expect someone to use this = variable.) And to =C3=93scar, I=E2=80=99m curious and interested to know what = indentation function you came up with; if it=E2=80=99s useful maybe we = can add it to Emacs? >=20 >> OTOH, the info node for "Parser-based Indentation" says: >>=20 >> To enable the parser-based indentation engine, either set >> =E2=80=98treesit-simple-indent-rules=E2=80=99 and call = =E2=80=98treesit-major-mode-setup=E2=80=99, or >> equivalently, set the value of =E2=80=98indent-line-function=E2=80=99 = to >> =E2=80=98treesit-indent=E2=80=99. >>=20 >> However, treesit-major-mode-setup does more than what's described = after >> "equivalently": >>=20 >> (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)) >=20 > So this is just a matter of updating the documentation to mention > indent-region-function? >=20 > I've added Yuan, in case he has comments or suggestions. I also updated the manual. Yuan= From unknown Mon Aug 18 19:27:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#71086: 30.0.50; Setting treesit-indent-function is not effective is treesit-simple-indent-rules is nil Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 22 May 2024 14:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71086 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Yuan Fu Cc: Eli Zaretskii , 71086@debbugs.gnu.org Received: via spool by 71086-submit@debbugs.gnu.org id=B71086.171638733013197 (code B ref 71086); Wed, 22 May 2024 14:16:01 +0000 Received: (at 71086) by debbugs.gnu.org; 22 May 2024 14:15:30 +0000 Received: from localhost ([127.0.0.1]:56207 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9mkc-0003Qn-Hj for submit@debbugs.gnu.org; Wed, 22 May 2024 10:15:30 -0400 Received: from relayout01-q01.e.movistar.es ([86.109.101.141]:48715) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9mkY-0003Qh-LA for 71086@debbugs.gnu.org; Wed, 22 May 2024 10:15:28 -0400 Received: from relayout01-redir.e.movistar.es (unknown [86.109.101.201]) by relayout01-out.e.movistar.es (Postfix) with ESMTP id 4VktcM2GmRzjYp2; Wed, 22 May 2024 16:15:15 +0200 (CEST) Received: from sky (81.red-81-39-130.dynamicip.rima-tde.net [81.39.130.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout01.e.movistar.es (Postfix) with ESMTPSA id 4VktcL2syPzfbNr; Wed, 22 May 2024 16:15:14 +0200 (CEST) From: =?UTF-8?Q?=C3=93scar?= Fuentes In-Reply-To: (Yuan Fu's message of "Tue, 21 May 2024 23:23:30 -0700") References: <87y184q7ai.fsf@telefonica.net> <86pltf8k61.fsf@gnu.org> Date: Wed, 22 May 2024 16:15:13 +0200 Message-ID: <87cypec4r2.fsf@telefonica.net> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-TnetOut-Country: IP: 81.39.130.81 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout01 X-TnetOut-MsgID: 4VktcL2syPzfbNr.A8B13 X-TnetOut-SpamCheck: no es spam, clean X-TnetOut-From: oscarfv@telefonica.net X-TnetOut-Watermark: 1716992115.0407@WkuHFo9YIvpiuABG2Fu2Xg X-Spam-Status: No X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Yuan Fu writes: > There are actually another level of customization between setting > treesit-simple-indent-rules and setting indent-line-function, which is > setting treesit-indent-function. IIUC =C3=93scar is trying to do that but > found out treesit-major-mode-setup doesn=E2=80=99t automatically setup > indent-line-functions when treesit-indent-function is set. More specifically, I found that treesit-major-mode-setup doesn't setup indentation when treesit-simple-indent-rules is *not* set, even when treesit-indent-function has been set. > I=E2=80=99ve now fixed that. Indeed, thank you. > (Though I didn=E2=80=99t expect someone to use this variable.) Why not? It is documented and the natural alternative when treesit-simple-indent-rules is not fit for the job, isn't it? > And to =C3=93scar, I=E2=80=99m curious and interested to know what indent= ation > function you came up with; if it=E2=80=99s useful maybe we can add it to > Emacs? I started with treesit-simple-indent-rules until I stumbled on something that it is not easily workable with the existing functions. My language has a Lisp syntax, and the problem was with indenting comments (and with how the presence of comments affected the indentation of other things). For instance, the typical indentation of (if p foo bar) That's simple enough to achieve with treesit-simple-indent-rules, but if we insert a comment: (if p ;; blah (foo) (bar)) things suddenly turn hairy. Likewise, starting with this: (progn (foo) (bar)) ... after inserting a comment, this is the desired indentation: (progn ;; blah (foo) (bar)) ... not this: (progn ;; blah (foo) (bar)) Maybe a variant of `match' and `nth-sibling' that take an argument of node types to skip would be enough to cover this case? That was basically what I did. Anyways, going the treesit-indent-function route was easy enough, and it is more powerful, flexible and future-proof. I don't think that treesit-simple-indent-rules would yield a significantly shorter and mantainable implementation. > I also updated the manual. Thanks! BTW, the treesit-based implementation of the major mode for this simple language is a tiny fraction of its traditional counterpart. And providing a great basis for adding more features :-) From unknown Mon Aug 18 19:27:51 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: =?UTF-8?Q?=C3=93scar?= Fuentes Subject: bug#71086: closed (Re: bug#71086: 30.0.50; Setting treesit-indent-function is not effective is treesit-simple-indent-rules is nil) Message-ID: References: <87r0df709d.fsf@telefonica.net> <87y184q7ai.fsf@telefonica.net> X-Gnu-PR-Message: they-closed 71086 X-Gnu-PR-Package: emacs Reply-To: 71086@debbugs.gnu.org Date: Sun, 02 Jun 2024 16:56:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1717347362-18495-1" This is a multi-part message in MIME format... ------------=_1717347362-18495-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #71086: 30.0.50; Setting treesit-indent-function is not effective is treesi= t-simple-indent-rules is nil which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 71086@debbugs.gnu.org. --=20 71086: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D71086 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1717347362-18495-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 71086-done) by debbugs.gnu.org; 2 Jun 2024 16:55:38 +0000 Received: from localhost ([127.0.0.1]:60207 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sDoUc-0004nh-0N for submit@debbugs.gnu.org; Sun, 02 Jun 2024 12:55:38 -0400 Received: from relayout03.e.movistar.es ([86.109.101.203]:20207 helo=relayout03-redir.e.movistar.es) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sDoUW-0004nP-Fo for 71086-done@debbugs.gnu.org; Sun, 02 Jun 2024 12:55:36 -0400 Received: from sky (81.red-81-39-130.dynamicip.rima-tde.net [81.39.130.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout03.e.movistar.es (Postfix) with ESMTPSA id 4Vsjdp6pVqzMl5m; Sun, 2 Jun 2024 18:55:10 +0200 (CEST) From: =?utf-8?Q?=C3=93scar_Fuentes?= To: 71086-done@debbugs.gnu.org Subject: Re: bug#71086: 30.0.50; Setting treesit-indent-function is not effective is treesit-simple-indent-rules is nil In-Reply-To: <86pltf8k61.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 21 May 2024 14:43:34 +0300") References: <87y184q7ai.fsf@telefonica.net> <86pltf8k61.fsf@gnu.org> Date: Sun, 02 Jun 2024 18:55:10 +0200 Message-ID: <87r0df709d.fsf@telefonica.net> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-TnetOut-Country: IP: 81.39.130.81 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout03 X-TnetOut-MsgID: 4Vsjdp6pVqzMl5m.AE827 X-TnetOut-SpamCheck: no es spam, clean X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1717952111.44122@i7Q+2wh73e5jfxy94iLyzw X-Spam-Status: No X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 71086-done Cc: , Yuan Fu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) As the issues reported here are solved, I'm closing the bug. ------------=_1717347362-18495-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 21 May 2024 01:32:36 +0000 Received: from localhost ([127.0.0.1]:46082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9EMm-0005F1-Dp for submit@debbugs.gnu.org; Mon, 20 May 2024 21:32:36 -0400 Received: from lists.gnu.org ([209.51.188.17]:34162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9EMj-0005Ev-Td for submit@debbugs.gnu.org; Mon, 20 May 2024 21:32:35 -0400 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 1s9EMe-0003IB-LO for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 21:32:28 -0400 Received: from relayout01-redir.e.movistar.es ([86.109.101.201]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9EMa-0005V6-Rj for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 21:32:28 -0400 Received: from sky (81.red-81-39-130.dynamicip.rima-tde.net [81.39.130.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout01.e.movistar.es (Postfix) with ESMTPSA id 4VjxkG3X9HzfcbT for ; Tue, 21 May 2024 03:32:06 +0200 (CEST) From: =?utf-8?Q?=C3=93scar_Fuentes?= To: bug-gnu-emacs@gnu.org Subject: 30.0.50; Setting treesit-indent-function is not effective is treesit-simple-indent-rules is nil X-Debbugs-Cc: Date: Tue, 21 May 2024 03:32:05 +0200 Message-ID: <87y184q7ai.fsf@telefonica.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-TnetOut-Country: IP: 81.39.130.81 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout01 X-TnetOut-MsgID: 4VjxkG3X9HzfcbT.AAD46 X-TnetOut-SpamCheck: no es spam, clean X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1716859926.80434@gpSdY53wPHO5hCm13SlNLA X-Spam-Status: No Received-SPF: softfail client-ip=86.109.101.201; envelope-from=ofv@wanadoo.es; helo=relayout01-redir.e.movistar.es 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) 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. Having to assign a dummy value to a variable that belongs to an API that is not used is surprising. Furthermore, it is unspecified what kind of values are acceptable on that scenario. I would expect that treesit-major-mode-setup shall setup indentation when treesit-indent-function is non-nil. OTOH, the info node for "Parser-based Indentation" says: To enable the parser-based indentation engine, either set =E2=80=98treesit-simple-indent-rules=E2=80=99 and call =E2=80=98treesit-m= ajor-mode-setup=E2=80=99, or equivalently, set the value of =E2=80=98indent-line-function=E2=80=99 to =E2=80=98treesit-indent=E2=80=99. 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)) In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.0) of 2024-05-19 built on sky Repository revision: 98b83bdc9f4af7798e3314ad8df6ab78efd60f8a Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101011 System Description: Debian GNU/Linux trixie/sid Configured using: 'configure --with-native-compilation --without-toolkit-scroll-bars --with-x-toolkit=3Dlucid --with-modules --without-imagemagick' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBOTF LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TREE_SITTER WEBP X11 XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: C locale-coding-system: nil ------------=_1717347362-18495-1--