From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu 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 23:23:30 -0700 Message-ID: References: <87y184q7ai.fsf@telefonica.net> <86pltf8k61.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.1\)) 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="37100"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?UTF-8?Q?=C3=93scar?= Fuentes , 71086@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 22 08:25:19 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 1s9fPb-0009RS-5P for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 22 May 2024 08:25:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9fPO-00040o-J0; Wed, 22 May 2024 02:25:06 -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 1s9fPF-0003zP-Em for bug-gnu-emacs@gnu.org; Wed, 22 May 2024 02:24:58 -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 1s9fPF-0006BA-1K for bug-gnu-emacs@gnu.org; Wed, 22 May 2024 02:24:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s9fPK-0006he-J9 for bug-gnu-emacs@gnu.org; Wed, 22 May 2024 02:25:02 -0400 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 71086-submit@debbugs.gnu.org id=B71086.171635910025740 (code B ref 71086); Wed, 22 May 2024 06:25:02 +0000 Original-Received: (at 71086) by debbugs.gnu.org; 22 May 2024 06:25:00 +0000 Original-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 Original-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 Original-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) Original-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) In-Reply-To: <86pltf8k61.fsf@gnu.org> X-Mailer: Apple Mail (2.3731.700.6.1.1) 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:285579 Archived-At: > 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=