GNU bug report logs - #61502
29.0.60; c-ts-mode auto-indent not working

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Pankaj Jangid <pankaj@HIDDEN>; dated Tue, 14 Feb 2023 04:37:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 18:18:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 13:18:59 2023
Received: from localhost ([127.0.0.1]:33938 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSMMt-00046f-A4
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 13:18:59 -0500
Received: from mail-wm1-f47.google.com ([209.85.128.47]:50967)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1pSMMp-00046Q-Vk
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 13:18:57 -0500
Received: by mail-wm1-f47.google.com with SMTP id n33so7973029wms.0
 for <61502 <at> debbugs.gnu.org>; Wed, 15 Feb 2023 10:18:55 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:from:to:cc:subject:date:message-id:reply-to;
 bh=NBHRNyKDAhqu6gpCC1dC23s0ZYXqNRguIgslxiRPJeU=;
 b=cjXbNHoVjRMN6Tpo4rWZx3rmZlrZhr3MNoMGFLSuOgNUf8KqR/YGXsmmZYZPl+oU34
 2EJVIxhV8uEzlSeVUzWkPAQ8+hBO7CsytYzmhCA+erxT1C3XYfC0xvuSrASYADvPrc2w
 4nMPE2L8xxp6Ubs030W9uIJVd3t6Lv2lCOH4BxL+LT8UV0W5Auuq5GB0yIIeHTMSAWFY
 P1iCZr4jBFY15pN82UwzVkxKf68T+9Bbsrfh3JUZpW5UfADdlQpsCcqYdE8i0Lc1TCgp
 r3zVmszaPoo31h7Q8FghkGY06lmqN5RRQVNDGA5rMuC7o/KgojjlnmzSgDJ/9RJjIg+g
 Ph5Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=NBHRNyKDAhqu6gpCC1dC23s0ZYXqNRguIgslxiRPJeU=;
 b=6jfxvnuHOqHB8h9+xrTAWLrR/8z+DH2AZnrSdZCrcJD6g+PxVezZc/4cUEmVke0oxi
 XoqQarxB8bAQcTVul8cptdeZEDaD2fwG+H5/tz1j3NG2YcM5HcGQgtZ26PfFsp8LZ8lb
 a+DMxTUtNPqTZjDAB1/VuPb3wxK82vcVAUDU5Zr2AollTsMhe0VOq2NdNUIgQVWEy2ak
 ldvRXJNmCe7No/YwXeg5Ho3Gabbupt0pIB/jKR6weFg28Rm29owP82G/m74tCzphBlFL
 Wuy03nfSMVlpM41IaFEvY7n4tziIyh0VUh50gy7qXSaISJkcxNqyQsWmj9KQj3OOXalw
 fIUA==
X-Gm-Message-State: AO0yUKWfsXKfg+gDkQqrQJWVcfSXGVHuT2fV8/S3UYQGwZ1etvro0YLA
 idI5RWu0DpWuFnEXQBn9IO4=
X-Google-Smtp-Source: AK7set+MhDzD60OqtEcatwA5U6OUuV9He1naQIkPfAwMVIA9jg3f1Cxjp0uJ4HYj0+pFMtCWRObCLg==
X-Received: by 2002:a05:600c:4d93:b0:3df:e549:bd00 with SMTP id
 v19-20020a05600c4d9300b003dfe549bd00mr3056860wmp.1.1676485130039; 
 Wed, 15 Feb 2023 10:18:50 -0800 (PST)
Received: from [192.168.0.2] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id
 t39-20020a05600c32a700b003e1e8d794e1sm2664412wmp.13.2023.02.15.10.18.48
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 15 Feb 2023 10:18:49 -0800 (PST)
Message-ID: <6611cbbe-d602-f70b-f7e9-cf31756efddf@HIDDEN>
Date: Wed, 15 Feb 2023 20:18:47 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.4.2
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
Content-Language: en-US
To: Eli Zaretskii <eliz@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN> <83a61fas5w.fsf@HIDDEN>
 <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN>
 <10bea2f6-6439-87fa-6523-1f992e396822@HIDDEN> <833576c0r3.fsf@HIDDEN>
 <00df07a1-4c58-95ec-81ae-fb43cd1626a8@HIDDEN> <83r0uqajds.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <83r0uqajds.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.9 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, theo@HIDDEN,
 pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.9 (-)

On 15/02/2023 20:11, Eli Zaretskii wrote:
> Sure, but I thought the problem was we were using the wrong nodes.  I
> presumed that, once the "right" node is found, we can thereafter use
> the information of that node (which is grammar-specific) to take it
> from there and determine the required indentation.  You seem to be
> saying there's more there than meets the eye?

I think the method of finding the correct node will need to be 
grammar-specific as well.

Note that this is mostly important for "incomplete" code. The users of 
electric-pair-mode should experience adequate indentation behavior already.

The for/if/else statements without curlies seem to be one of the few 
exceptions, but that the user also might be typing "{" next, in which 
case the current indentation will be the correct one.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 18:12:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 13:12:12 2023
Received: from localhost ([127.0.0.1]:33924 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSMGK-0003vp-9B
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 13:12:12 -0500
Received: from eggs.gnu.org ([209.51.188.92]:40028)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pSMGI-0003vd-Aj
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 13:12:11 -0500
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 <eliz@HIDDEN>)
 id 1pSMGA-0002co-Mz; Wed, 15 Feb 2023 13:12:04 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=ZlhbrFF1m10SoeymKi3kPk62QhTrEsYaxAbyMCP/dOc=; b=TdvKD4dRntFl
 ypH0OjGT9g/Caqi6xPeHABusrP4KlOtZyMtqE3qJVf+3VhV3G1xTNkXIg+sqLnCbMTNDHApFcrooA
 vFVjxanEnwUVvolyYnHpjBmRhuvMRUcgm2H9aXBaD696MtR9pp2Nm1ssgXJE5852OB8BULn8fZRPb
 8IqPcFytNm9667Dho/H3nk/8Ra9yvoyxOXvh2+7UQOyUXi9xnRElfCkWP1iPlZlnMvpC2RUckRkl9
 tSH3Jm3QK7sN4WkpaQKuZYzf3kTqtjxCBpIP6snQXglPTxpbPK/dFjNtyR0GZR6ZKCuKeFANQhDD8
 eXGMudS3r9EtWTdDpAakLA==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pSMG9-0006DY-Vp; Wed, 15 Feb 2023 13:12:02 -0500
Date: Wed, 15 Feb 2023 20:11:43 +0200
Message-Id: <83r0uqajds.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <00df07a1-4c58-95ec-81ae-fb43cd1626a8@HIDDEN> (message from
 Dmitry Gutov on Wed, 15 Feb 2023 19:57:04 +0200)
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN> <83a61fas5w.fsf@HIDDEN>
 <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN>
 <10bea2f6-6439-87fa-6523-1f992e396822@HIDDEN> <833576c0r3.fsf@HIDDEN>
 <00df07a1-4c58-95ec-81ae-fb43cd1626a8@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, theo@HIDDEN,
 pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Wed, 15 Feb 2023 19:57:04 +0200
> Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, theo@HIDDEN,
>  pankaj@HIDDEN
> From: Dmitry Gutov <dgutov@HIDDEN>
> 
> On 15/02/2023 19:11, Eli Zaretskii wrote:
> >> Date: Wed, 15 Feb 2023 17:57:51 +0200
> >> Cc:61502 <at> debbugs.gnu.org,casouri@HIDDEN,pankaj@HIDDEN
> >> From: Dmitry Gutov<dgutov@HIDDEN>
> >>
> >> On 15/02/2023 17:48, Theodor Thornhill via Bug reports for GNU Emacs,
> >> the Swiss army knife of text editors wrote:
> >>> For indentation purposes, when RET is pressed, shouldn't we
> >>> ask about the node of the first non-whitespace character of the line
> >>> where we get RET?
> >> RET usually indents two lines now: the current one and the next.
> >>
> >> The issue is what to do about indentation on the next (opened) line.
> > Yes, I tried to suggest that for the indentation of the next line we
> > find the node that corresponds to the beginning of the current line.
> > That assumes that we already know how to indent a line after "for" (or
> > "if" or "while" or...).
> 
> If the current line is empty, we could indeed look for the node at the 
> end of the previous line.
> 
> But to determine whether that node is an opener, or a closer, or a 
> container that should have spanned the current line (or should be 
> considered to do so), I think will require grammar-specific logic.

Sure, but I thought the problem was we were using the wrong nodes.  I
presumed that, once the "right" node is found, we can thereafter use
the information of that node (which is grammar-specific) to take it
from there and determine the required indentation.  You seem to be
saying there's more there than meets the eye?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 17:57:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 12:57:17 2023
Received: from localhost ([127.0.0.1]:33881 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSM1s-0003W1-RS
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:57:17 -0500
Received: from mail-ed1-f53.google.com ([209.85.208.53]:40687)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1pSM1p-0003Vj-7M
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:57:15 -0500
Received: by mail-ed1-f53.google.com with SMTP id fi26so23959320edb.7
 for <61502 <at> debbugs.gnu.org>; Wed, 15 Feb 2023 09:57:13 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:from:to:cc:subject:date:message-id:reply-to;
 bh=nk1zD1bRcmIhzD6NB91dbSlcYrZIowIiNvhIX02dTn4=;
 b=fhdTBOGQRLJU9p/vTdJCDthyJwA5hbVBCQpJD39yh7XVAs1PI1TSyRxvprIK1fRbaW
 FYZPX65nMKvoe3GBjQhCmL7s1WJpJP2Z0lQaVZdullzuaiOTmv1yUVtmOeICsIskW2J1
 qJ3Rzsv2LlwHoB7Z3gUUGIcDC3DE84DUJjB7nZMzqCG6vRJlj0Up2/k/E4ozDzHqP2Ah
 f2Ucny5RKI2gvO8GNddxvH19mJ7FIbAYwnhKY9OIIlDhyrjrC4rleoCaHB7020vvKbNI
 cAoQ1knb1sSkyJKjkdkzjX1zIm1doQUzN44YWgdaseFGNh8aIw9BAm4vXnklLSD8jF1H
 EELQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=nk1zD1bRcmIhzD6NB91dbSlcYrZIowIiNvhIX02dTn4=;
 b=3Dlg1Fh3ArszX59mACfxxRFx4WJba7zysF8XlJw8sOVDIZhN5Gx+4HidSdFNqt/6XY
 cT5uJL8lJ4V2D3p/ASIMx1YfP/PkgMOr5et9RTkR6nZUdRKELpRRR7MGhztUE5M2XiOk
 ovoM5WcHAqWLeGCn7p7uPdCb4FYZXpemz+HEdYt16sxS2lS88OjuvrgyfmQgQhpcO4Qh
 p2JU+4f8nuFERBQn1ovt+tLgDl6HdAqEIPRUiYRJEjrYbxupWE+oIw8rV57uIPqpmbga
 d2DBhBew06cR7VWAowMEGzxtPQR8cNcKauobckrWqSDZ/UEyk+omZSFcwNqASeWRb9Si
 JdrQ==
X-Gm-Message-State: AO0yUKVEXQBGFMpvRAqE+ZKmIDn+VMOSXI0dMGLdxyTydbdREurGP3St
 HAiOpSixjGmtdshJXWppU4k=
X-Google-Smtp-Source: AK7set/p8a7QPetvoMR8YQFrh7zajxG8A+U2PLQplsp1uoztSvA/hBkwsDv/tgWS/QYzwMXhG9bPmQ==
X-Received: by 2002:a17:907:96a0:b0:8a4:7fb9:5656 with SMTP id
 hd32-20020a17090796a000b008a47fb95656mr3743854ejc.57.1676483827162; 
 Wed, 15 Feb 2023 09:57:07 -0800 (PST)
Received: from [192.168.0.2] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id
 f13-20020a170906c08d00b00878003adeeesm9936223ejz.23.2023.02.15.09.57.05
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 15 Feb 2023 09:57:06 -0800 (PST)
Message-ID: <00df07a1-4c58-95ec-81ae-fb43cd1626a8@HIDDEN>
Date: Wed, 15 Feb 2023 19:57:04 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.4.2
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
Content-Language: en-US
To: Eli Zaretskii <eliz@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN> <83a61fas5w.fsf@HIDDEN>
 <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN>
 <10bea2f6-6439-87fa-6523-1f992e396822@HIDDEN> <833576c0r3.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <833576c0r3.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.1 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, theo@HIDDEN,
 pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.9 (-)

On 15/02/2023 19:11, Eli Zaretskii wrote:
>> Date: Wed, 15 Feb 2023 17:57:51 +0200
>> Cc:61502 <at> debbugs.gnu.org,casouri@HIDDEN,pankaj@HIDDEN
>> From: Dmitry Gutov<dgutov@HIDDEN>
>>
>> On 15/02/2023 17:48, Theodor Thornhill via Bug reports for GNU Emacs,
>> the Swiss army knife of text editors wrote:
>>> For indentation purposes, when RET is pressed, shouldn't we
>>> ask about the node of the first non-whitespace character of the line
>>> where we get RET?
>> RET usually indents two lines now: the current one and the next.
>>
>> The issue is what to do about indentation on the next (opened) line.
> Yes, I tried to suggest that for the indentation of the next line we
> find the node that corresponds to the beginning of the current line.
> That assumes that we already know how to indent a line after "for" (or
> "if" or "while" or...).

If the current line is empty, we could indeed look for the node at the 
end of the previous line.

But to determine whether that node is an opener, or a closer, or a 
container that should have spanned the current line (or should be 
considered to do so), I think will require grammar-specific logic.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 17:52:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 12:52:46 2023
Received: from localhost ([127.0.0.1]:33877 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSLxW-0003P3-4U
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:52:46 -0500
Received: from out-21.mta0.migadu.com ([91.218.175.21]:62286)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pSLxT-0003Ot-Ak
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:52:44 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1676483561;
 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=J0Uh79rjbH/mVHSiyZw6r4dPAYttNgd6UGthc9+86AY=;
 b=hGTSxBk9gSrg/rGEXomC13bK+PyV5mNtyb1Fd76LQW1gqr/UfhPmkvO0wnMbeMok2mHGml
 pxIjLLizBDKF62spYIy42CBO3nYcv9Wh4dU40TZB/CqalvCdbstaka+00TXD4JEXmQ9zTN
 jFV8nUmjd+V4PkssoY/hHlsiPr7zYgmo+KWLeDYlu0cv+IIkwbrQMuLUkDXcYe7r+TT3Td
 dkVNWcqiAWo/FTGkVSRmPlK7jC4AJAsPduDtTK6b1/PP+mVDN1p8Cz31vWSXl8ZxgLbu4u
 V5BruRcLIchVRLSOP1Zr143fTvqHibESoAiwkvdyx94gB7xWpmcz0bU77U4tfw==
From: Theodor Thornhill <theo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
In-Reply-To: <83y1oyal9z.fsf@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN> <83a61fas5w.fsf@HIDDEN>
 <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN>
 <834jrmc0u9.fsf@HIDDEN>
 <4D34D384-C36F-47F1-A1D7-DA4C85B53316@HIDDEN>
 <83y1oyal9z.fsf@HIDDEN>
Date: Wed, 15 Feb 2023 18:52:39 +0100
Message-ID: <87o7pu7r4o.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> Date: Wed, 15 Feb 2023 18:14:46 +0100
>> From: Theodor Thornhill <theo@HIDDEN>
>> CC: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
>> 
>> >Look back for the first line that has something other than whitespace?
>> 
>> Yeah, we could. But what then with
>> 
>> for (
>>      ;;)
>> |
>> 
>> ?
>> 
>> Not saying it's impossible, but we will get complexity that may be hard to get into emacs-29, i think.
>
> At some point we will have to rely on electric characters to fix the
> indentation later.  We just need to try to fix the more blatant and
> simple situations, I think, and punt (for now) where it becomes hairy.
>
> I wonder, though: what do other IDEs which use tree-sitter do in these
> cases?

Most of them avoid the whole emacs' tradition of guessing. They usually
just indent and deindent on block openers, otherwise just keep the
previous line indent level.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 17:31:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 12:31:19 2023
Received: from localhost ([127.0.0.1]:33837 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSLcl-0002nA-Cl
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:31:19 -0500
Received: from eggs.gnu.org ([209.51.188.92]:54100)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pSLcg-0002mt-6l
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:31:17 -0500
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 <eliz@HIDDEN>)
 id 1pSLca-0007fr-0b; Wed, 15 Feb 2023 12:31:08 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=1Fxkce2FIC2txfw7CJOxFDOp6TUHK5AgWRhjNV5iCJY=; b=TWl0RebE/xga
 PNMLjI9EOeVfAaalz1wlviBlCwk7+oMRgZT9mE2nmMZd4SDyDbJ1P5kk+/dZ7GqwHhQVOBc9CjnIs
 4RFLGMbIebsgZnlbIT+OoQdft+ql1Xos7+4w0BEHou/aF4ImYw5B2hyP7kGZR+cwrq9BLU3xhG//G
 mfvdRym0mP2KVOYNC4a/C+HM4q0pkifLSa1dUu+yXGG0WPKttoyG1fFejXhj+/Jj36VXlWRHHemu7
 yR4K2Ei3VHnX4ZYfewAMjWzvTtsPV9VRukuRpQp3yOtFGjJ9XCuR2xKDjD2C5cklXIPvdSUxv4PtC
 o7kIx0xsINLD8M0unqmEmQ==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pSLcZ-0003ti-G6; Wed, 15 Feb 2023 12:31:07 -0500
Date: Wed, 15 Feb 2023 19:30:48 +0200
Message-Id: <83y1oyal9z.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
In-Reply-To: <4D34D384-C36F-47F1-A1D7-DA4C85B53316@HIDDEN> (message from
 Theodor Thornhill on Wed, 15 Feb 2023 18:14:46 +0100)
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN> <83a61fas5w.fsf@HIDDEN>
 <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN> <834jrmc0u9.fsf@HIDDEN>
 <4D34D384-C36F-47F1-A1D7-DA4C85B53316@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Wed, 15 Feb 2023 18:14:46 +0100
> From: Theodor Thornhill <theo@HIDDEN>
> CC: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
> 
> >Look back for the first line that has something other than whitespace?
> 
> Yeah, we could. But what then with
> 
> for (
>      ;;)
> |
> 
> ?
> 
> Not saying it's impossible, but we will get complexity that may be hard to get into emacs-29, i think.

At some point we will have to rely on electric characters to fix the
indentation later.  We just need to try to fix the more blatant and
simple situations, I think, and punt (for now) where it becomes hairy.

I wonder, though: what do other IDEs which use tree-sitter do in these
cases?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 17:14:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 12:14:59 2023
Received: from localhost ([127.0.0.1]:33831 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSLMu-0002Mk-4o
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:14:59 -0500
Received: from out-235.mta1.migadu.com ([95.215.58.235]:10084)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pSLMo-0002MS-SR
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:14:54 -0500
Date: Wed, 15 Feb 2023 18:14:46 +0100
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1676481289;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=jVzDCgX7p5VA6jfDX7kL7CO/WQxKraDawTsBTb9R0UQ=;
 b=HvEfTEuxpKgGULGFgN3Nt+k0883AVjpfxc+Tl9cdv6/vzE+7y2OPluyB0kPf24WPq9bwGQ
 /ZCLpeKZGCU22r4rXt6dIsQJ1GEbOZLNcfe2XngAkqRMryXmW8qeBQElPIeJnQryC/mAic
 QU2NDaTyeT2uhNlwykhUbSlf1DQ+TvcfWulv/HuN/XgnLTTyfKSL60Ft4ySLUNmVJNKvJG
 b8hPjmUGdARUKpOu3agaarVgcor7B176Mnity1evvmndSobcAedoFwggaVRo8AfDsq+J9V
 nriD5VifrplBoV4Nx2HCkE1eT3aO4VhFj8KZaMiapfZi9pHv2IbBPhUFWER5vQ==
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
In-Reply-To: <834jrmc0u9.fsf@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN> <83a61fas5w.fsf@HIDDEN>
 <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN> <834jrmc0u9.fsf@HIDDEN>
Message-ID: <4D34D384-C36F-47F1-A1D7-DA4C85B53316@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



On 15 February 2023 18:09:18 CET, Eli Zaretskii <eliz@gnu=2Eorg> wrote:
>> Date: Wed, 15 Feb 2023 16:48:33 +0100
>> From: Theodor Thornhill <theo@thornhill=2Eno>
>> CC: pankaj@codeisgreat=2Eorg, casouri@gmail=2Ecom, 61502@debbugs=2Egnu=
=2Eorg
>>=20
>>=20
>>=20
>> On 15 February 2023 16:02:03 CET, Eli Zaretskii <eliz@gnu=2Eorg> wrote:
>> >> From: Theodor Thornhill <theo@thornhill=2Eno>
>> >> Cc: pankaj@codeisgreat=2Eorg, casouri@gmail=2Ecom, 61502@debbugs=2Eg=
nu=2Eorg
>> >> Date: Wed, 15 Feb 2023 15:53:22 +0100
>> >>=20
>> >> >> int
>> >> >> main
>> >> >> {
>> >> >>   for (;;)
>> >> >> |
>> >> >>=20
>> >> >> eval: (treesit-node-at (point)) ;; #<treesit-node ")" in 21-22>
>> >> >
>> >> > I'm afraid I cannot interpret that=2E  What does it mean?
>> >>=20
>> >> It returns the closing paren in "for (;;)", right before point=2E  W=
hich
>> >> may not be as useful, as it is a child of for_statement, IIRC=2E  Ma=
king a
>> >> rule for that isn't too hard, but it complicates things=2E
>> >
>> >Hmm=2E=2E=2E this might make no sense, but: why are we asking about th=
e node
>> >at point?  For indentation purposes, when RET is pressed, shouldn't we
>> >ask about the node of the first non-whitespace character of the line
>> >where we get RET?
>>=20
>> Yeah, but what then to do when there is only whitespace?
>
>Look back for the first line that has something other than whitespace?

Yeah, we could=2E But what then with

for (
     ;;)
|

?

Not saying it's impossible, but we will get complexity that may be hard to=
 get into emacs-29, i think=2E

Theo=20




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 17:11:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 12:11:37 2023
Received: from localhost ([127.0.0.1]:33826 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSLJh-0002Hl-HT
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:11:37 -0500
Received: from eggs.gnu.org ([209.51.188.92]:60190)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pSLJf-0002HV-Pj
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:11:36 -0500
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 <eliz@HIDDEN>)
 id 1pSLJa-0001Ek-BD; Wed, 15 Feb 2023 12:11:30 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=lINgvqGLgTvZHxDs6h1kFJP7ENMPrJoOa+cI+0P5hbQ=; b=OqpyOckhsKnF
 KKUik8rnuQjSRniZoCKQ6Qgiz4mGNbnmjXAZ15uKoioZ83st+Shgf2ZNVIJx6Su8HJyqRX5jl/9/C
 jPlMmwbeWQlg97puM7vnltOnmPprltWKCKYZD94LjPAOjvLZowTh2+kMNYhJqfzJnmqQ2Uin5szK6
 rwJacK99XrKZXbwFSyt9BWwOTtdM/egWyE7bVhqEBvCf/aljV6Pjs4D7QWql8qY4Pd6LRzzDipIh8
 COOAUuyov1bQuGd4jZmEUtp7b1mFY33kCWc+GzlRVFFqeIQ98Bv4pSIoqxihJDvPwd/rCqhJo9Nhh
 6VgCrwn9QqqllZfV9hSQYg==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pSLJZ-0005Xl-L4; Wed, 15 Feb 2023 12:11:29 -0500
Date: Wed, 15 Feb 2023 19:11:12 +0200
Message-Id: <833576c0r3.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <10bea2f6-6439-87fa-6523-1f992e396822@HIDDEN> (message from
 Dmitry Gutov on Wed, 15 Feb 2023 17:57:51 +0200)
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN> <83a61fas5w.fsf@HIDDEN>
 <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN>
 <10bea2f6-6439-87fa-6523-1f992e396822@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, theo@HIDDEN,
 pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Wed, 15 Feb 2023 17:57:51 +0200
> Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
> From: Dmitry Gutov <dgutov@HIDDEN>
> 
> On 15/02/2023 17:48, Theodor Thornhill via Bug reports for GNU Emacs, 
> the Swiss army knife of text editors wrote:
> > For indentation purposes, when RET is pressed, shouldn't we
> > ask about the node of the first non-whitespace character of the line
> > where we get RET?
> 
> RET usually indents two lines now: the current one and the next.
> 
> The issue is what to do about indentation on the next (opened) line.

Yes, I tried to suggest that for the indentation of the next line we
find the node that corresponds to the beginning of the current line.
That assumes that we already know how to indent a line after "for" (or
"if" or "while" or...).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 17:09:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 12:09:45 2023
Received: from localhost ([127.0.0.1]:33820 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSLHt-0002Ea-1j
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:09:45 -0500
Received: from eggs.gnu.org ([209.51.188.92]:50078)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pSLHr-0002EJ-6i
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 12:09:43 -0500
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 <eliz@HIDDEN>)
 id 1pSLHl-0007bT-Kt; Wed, 15 Feb 2023 12:09:37 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=3M3Mh2tZnGpZvBm0Ocylz3sUa+utufxRzPu9XrfKSGE=; b=hPJK+waGQeFO
 vaP7856H1o1vOMJsoekMVY8InVz5Dv4/xRniHnjqWqOCufWrK/QyjQESKW5GyQxXj69FFSoEepeao
 3Db7fa9pgkKbIPpgfKfUEBJcEhOcXVJuqe7ib0RVb7gUKEPKIUsTjTnvBnjTDc2uGveseqf2LBIT9
 17v4YPlt/uf8nVr4n5v0S+naSbRWkaifd1W3KP1tcWEsFRczuRalj83iwsd/nVNCjtdOS/336na7l
 J9ZUzgyjxTtVEmVOapEtwWiuu0NWR2wnZDMG0Fkvo/C7n6fRrM+W+FcUc5XHJZWjwvjAz/T6Rw7jj
 +zZRpjGRVgisICEu1yNYHw==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pSLHl-0005HJ-2C; Wed, 15 Feb 2023 12:09:37 -0500
Date: Wed, 15 Feb 2023 19:09:18 +0200
Message-Id: <834jrmc0u9.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
In-Reply-To: <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN> (message from
 Theodor Thornhill on Wed, 15 Feb 2023 16:48:33 +0100)
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN> <83a61fas5w.fsf@HIDDEN>
 <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Wed, 15 Feb 2023 16:48:33 +0100
> From: Theodor Thornhill <theo@HIDDEN>
> CC: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
> 
> 
> 
> On 15 February 2023 16:02:03 CET, Eli Zaretskii <eliz@HIDDEN> wrote:
> >> From: Theodor Thornhill <theo@HIDDEN>
> >> Cc: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
> >> Date: Wed, 15 Feb 2023 15:53:22 +0100
> >> 
> >> >> int
> >> >> main
> >> >> {
> >> >>   for (;;)
> >> >> |
> >> >> 
> >> >> eval: (treesit-node-at (point)) ;; #<treesit-node ")" in 21-22>
> >> >
> >> > I'm afraid I cannot interpret that.  What does it mean?
> >> 
> >> It returns the closing paren in "for (;;)", right before point.  Which
> >> may not be as useful, as it is a child of for_statement, IIRC.  Making a
> >> rule for that isn't too hard, but it complicates things.
> >
> >Hmm... this might make no sense, but: why are we asking about the node
> >at point?  For indentation purposes, when RET is pressed, shouldn't we
> >ask about the node of the first non-whitespace character of the line
> >where we get RET?
> 
> Yeah, but what then to do when there is only whitespace?

Look back for the first line that has something other than whitespace?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 15:58:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 10:58:02 2023
Received: from localhost ([127.0.0.1]:33694 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSKAU-000068-0q
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 10:58:02 -0500
Received: from mail-ed1-f43.google.com ([209.85.208.43]:39553)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1pSKAS-00005r-AK
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 10:58:01 -0500
Received: by mail-ed1-f43.google.com with SMTP id eq11so22789803edb.6
 for <61502 <at> debbugs.gnu.org>; Wed, 15 Feb 2023 07:58:00 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:from:to:cc:subject:date:message-id:reply-to;
 bh=88QZw3A5HEgI6TrxXF9SOml9iEwu18AccRNbDJ09DT4=;
 b=h0snCGXJkar0heBurbOTbR+eE1Gr8AApjRl0XoTua4mwIrjULWA9KuzpwbbCc2omTz
 a7HX1wXKoWK17P2hr4xRL94NhxXroMsG/70H6G8dtfw+AxSzNUvKDRo3cXnCYNKO0KvO
 b6rMAtB5/uNNpbO95LirtviE+W/wt+EX2EakM1LsFfob8IfLz2kDM9lnRCWQ9r/J996n
 pwv6CgZEXYwXBPGXC+uaAqGjoYYj1ln5Y96ELEh4V8WAUNM8bQ1R5NrTALPRqevMK/NH
 Lc0vCfaCqRZ502JzeDOTvsOaJ6XgktjJ6Oc9wRDKA6OKtukl++3Qfyitft+tykx1zrvl
 l5Ig==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=88QZw3A5HEgI6TrxXF9SOml9iEwu18AccRNbDJ09DT4=;
 b=xq3CmfeoDMk+f0mfbA7Gw62rOdojP8WWts9cZfrec3nY+lc9TXa8JX+JKZUyswTuTJ
 uEUEc5Ug0CVsUe5FYfTH9Wok0sdm/U1Xn1+jzxpOeF8mPBOhVxqviwC9XD/7Be5tEpkF
 1dEXSggCPMVgAY+03Ea27jW+PkIz4nfqiJTl5LFjN6pExQohhhKVu12RH62ShUtiDboq
 0u6YIy0ex0PTc/RYwStlG1C2Hh4RCV+1MxMKzeqaSN7jSNEdzWV4VESmzB8Jnbi5NEc+
 4p+EAlaNzWuctwmg6Wirl386pb4JYA40AjIm/aiMfu4Fp+5zWv26xEN63R+mI2x6uTRW
 uldg==
X-Gm-Message-State: AO0yUKX5y3rhZ27U/9MGLoYHUzq/NYeriFZVhuHjtgpXxqaUeYzrX9/F
 jap8IWTPvBiYLEsLlRvnFY4=
X-Google-Smtp-Source: AK7set+pz9ojhBEXwkixZzxj/18kd8F5dOyb61Nq1nHdzu4VyIUW+54FR45tHkb/aUc1tWp6kxyoaw==
X-Received: by 2002:a05:6402:1804:b0:4a2:6573:5c35 with SMTP id
 g4-20020a056402180400b004a265735c35mr2413851edy.21.1676476674137; 
 Wed, 15 Feb 2023 07:57:54 -0800 (PST)
Received: from [192.168.0.2] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id
 k4-20020a50ce44000000b004acb3de92e2sm7392094edj.13.2023.02.15.07.57.52
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 15 Feb 2023 07:57:53 -0800 (PST)
Message-ID: <10bea2f6-6439-87fa-6523-1f992e396822@HIDDEN>
Date: Wed, 15 Feb 2023 17:57:51 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.4.2
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
Content-Language: en-US
To: Theodor Thornhill <theo@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN> <83a61fas5w.fsf@HIDDEN>
 <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.9 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.9 (-)

On 15/02/2023 17:48, Theodor Thornhill via Bug reports for GNU Emacs, 
the Swiss army knife of text editors wrote:
> For indentation purposes, when RET is pressed, shouldn't we
> ask about the node of the first non-whitespace character of the line
> where we get RET?

RET usually indents two lines now: the current one and the next.

The issue is what to do about indentation on the next (opened) line.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 15:48:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 10:48:41 2023
Received: from localhost ([127.0.0.1]:33672 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSK1Q-0008ID-Sk
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 10:48:41 -0500
Received: from out-191.mta1.migadu.com ([95.215.58.191]:55584)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pSK1O-0008I5-B0
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 10:48:39 -0500
Date: Wed, 15 Feb 2023 16:48:33 +0100
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1676476117;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=XngkWCmTuUfde2K05en0dT6lO+fTDA/ZtVf/eflE7IE=;
 b=e699u1U1muAoCG8r4eblmTRvULtU1YbN/2VnBWHO5JxqxIh9cumexM2ojuBHIB5Cohm5OX
 g1ou/Ubak1A0edc0KgNsV70uBDmXCwC+ygbCNLg359hsIiaD9bvclWMmiv1tqJCU80kU8s
 p2drd0fsI70u3ES4kwGqvZlzwlvAYSAgLwjX74wDIsHVYJQjs0CK8tOxeXQU4pz7HPxKSA
 LiUZUkdeGJdo/tOzIxdJ6uymOHoxaMcFFhtQAlR8i28Sn+N8OXjMf7uRQl9YpVIOSdnPFV
 WEpN5Yvc0IHPHjZpHf10Po2CAxy/avqwQYGiMgXkYfPJ/bppNY9OdbiEGCZ5bw==
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
In-Reply-To: <83a61fas5w.fsf@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN> <83a61fas5w.fsf@HIDDEN>
Message-ID: <6AAA6F2C-605C-4C90-9B3B-9223A9707A43@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



On 15 February 2023 16:02:03 CET, Eli Zaretskii <eliz@gnu=2Eorg> wrote:
>> From: Theodor Thornhill <theo@thornhill=2Eno>
>> Cc: pankaj@codeisgreat=2Eorg, casouri@gmail=2Ecom, 61502@debbugs=2Egnu=
=2Eorg
>> Date: Wed, 15 Feb 2023 15:53:22 +0100
>>=20
>> >> int
>> >> main
>> >> {
>> >>   for (;;)
>> >> |
>> >>=20
>> >> eval: (treesit-node-at (point)) ;; #<treesit-node ")" in 21-22>
>> >
>> > I'm afraid I cannot interpret that=2E  What does it mean?
>>=20
>> It returns the closing paren in "for (;;)", right before point=2E  Whic=
h
>> may not be as useful, as it is a child of for_statement, IIRC=2E  Makin=
g a
>> rule for that isn't too hard, but it complicates things=2E
>
>Hmm=2E=2E=2E this might make no sense, but: why are we asking about the n=
ode
>at point?  For indentation purposes, when RET is pressed, shouldn't we
>ask about the node of the first non-whitespace character of the line
>where we get RET?

Yeah, but what then to do when there is only whitespace?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 15:02:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 10:02:33 2023
Received: from localhost ([127.0.0.1]:33578 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSJIm-0006en-Vq
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 10:02:33 -0500
Received: from eggs.gnu.org ([209.51.188.92]:51046)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pSJIj-0006ea-PI
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 10:02:32 -0500
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 <eliz@HIDDEN>)
 id 1pSJId-0004nP-Ch; Wed, 15 Feb 2023 10:02:23 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=9ka6R96AjqJk9SwshKn4SXv3qWJKEB78TLhOkoXeUFI=; b=JQxlufTI3hN3
 xc4wnL6yA0k2uP/ah50p/xB5MLm2DafMQGL08Z3rn+TgkpXza1hqiBMJnl7tKherHGks6sWxyHLmP
 CjoS2CCx3ta/gk1Ooy9tm7G+a8R9rloHgDBdMMy4w0sOZ6Xl7Yexx768vJPutAg42K6UfSrF3FgDH
 VomnktFR1QkufeD8uO4O+KD3PaSo6+8YtIqwutmGW/Af0UeuSMVHe0RQOOP4uPvbrj1lL5P2Bzm9w
 CGOME62mOD4TVQR8IJ75gm7yea/r5IZxnihchk2N0Ki51nb8qbojAlEv7fnDA26QAe4d73tJjMM3e
 UD3S9vBL7z839UH2zps6MQ==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pSJIc-0007qF-QQ; Wed, 15 Feb 2023 10:02:23 -0500
Date: Wed, 15 Feb 2023 17:02:03 +0200
Message-Id: <83a61fas5w.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
In-Reply-To: <87r0ur6kv1.fsf@HIDDEN> (message from Theodor Thornhill on
 Wed, 15 Feb 2023 15:53:22 +0100)
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
 <87r0ur6kv1.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Theodor Thornhill <theo@HIDDEN>
> Cc: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
> Date: Wed, 15 Feb 2023 15:53:22 +0100
> 
> >> int
> >> main
> >> {
> >>   for (;;)
> >> |
> >> 
> >> eval: (treesit-node-at (point)) ;; #<treesit-node ")" in 21-22>
> >
> > I'm afraid I cannot interpret that.  What does it mean?
> 
> It returns the closing paren in "for (;;)", right before point.  Which
> may not be as useful, as it is a child of for_statement, IIRC.  Making a
> rule for that isn't too hard, but it complicates things.

Hmm... this might make no sense, but: why are we asking about the node
at point?  For indentation purposes, when RET is pressed, shouldn't we
ask about the node of the first non-whitespace character of the line
where we get RET?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 14:53:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 09:53:30 2023
Received: from localhost ([127.0.0.1]:58458 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSJA2-0005ZW-Kk
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 09:53:30 -0500
Received: from out-180.mta0.migadu.com ([91.218.175.180]:42866)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pSJ9x-0005ZF-S7
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 09:53:28 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1676472804;
 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=I7RUWkiG8ZlFzetEVfcinyBk4EbVqBvLTLQJSvQNi0k=;
 b=b8EMDoNLlSY6T2zew27KHJebHryZIiuqvdX+xmt0z4833F3xxKXn9jzdyi+WaW5qEnOYFJ
 x8OhoxEXv6lT6dKIdGz7PHf7+E9YEoTehmqnwJfaF2DDKAdqvVgxmJfkBV5o+Q2kFlr6yS
 FSKoPwhBaWmalTydHXMJmM2yUdNIM4SMY1lFARkccd+7UPuYqWfWLOPFWRHOp9HTVENGnp
 eDlZ+t1wcRYAbaFi6Nj0gfK5u4W6eEZlKVBdk0XlnbgGMynJYbDPzRMHjXvbDqUg60s53o
 /KjAsSdFZVPn5tlQ+PzjG/vSZm5Yo57Prvt0KjVZHDsjeLkV20SSUtNaE0ZoWg==
From: Theodor Thornhill <theo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
In-Reply-To: <83bklvatrj.fsf@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN> <83bklvatrj.fsf@HIDDEN>
Date: Wed, 15 Feb 2023 15:53:22 +0100
Message-ID: <87r0ur6kv1.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Theodor Thornhill <theo@HIDDEN>
>> Cc: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
>> Date: Wed, 15 Feb 2023 15:21:11 +0100
>> 
>> Eli Zaretskii <eliz@HIDDEN> writes:
>> 
>> > What happens if you indeed call treesit-node-at, as the doc string
>> > suggests?
>> 
>> 
>> int
>> main
>> {
>>   for (;;)
>> |
>> 
>> eval: (treesit-node-at (point)) ;; #<treesit-node ")" in 21-22>
>
> I'm afraid I cannot interpret that.  What does it mean?

It returns the closing paren in "for (;;)", right before point.  Which
may not be as useful, as it is a child of for_statement, IIRC.  Making a
rule for that isn't too hard, but it complicates things.

Theo




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 14:27:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 09:27:54 2023
Received: from localhost ([127.0.0.1]:58372 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSIlG-0004nH-Kq
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 09:27:54 -0500
Received: from eggs.gnu.org ([209.51.188.92]:36598)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pSIlF-0004n3-Hn
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 09:27:53 -0500
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 <eliz@HIDDEN>)
 id 1pSIl9-0004TN-RN; Wed, 15 Feb 2023 09:27:47 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=D+fWhJ1NXh/BilqVda3GuahxOTWtGJSMDqNiUsf5Kws=; b=SBddfa0A8XRl
 7MwbDx69vaNGW51YK00Lo/L/FyHTL6bVx9dubgk8/eX+N5vgpdANPFujfaanvQCjm6EXUvyQBneBf
 ElvQddLqYTRlcoIc0KEAi31WiUGnbY2MsguId3rYqTvbzYUqxMO0VJZKBx9HoZD+9E5gx/KCoa8EM
 Hth8f1xey5/OpKBpnnLu5hfl5qi9ojRzPyhDFulxhOPPsO8z5rsKIhh5HRdejEdegyE9TpL+lOhv4
 EPACx4JRLc2CSkBFPCsCdCUQv3briUx8lVljs9swa8yxkq/TJCcfUU/Nvd+whEZ3BAsyUyjrHhI6V
 a0VYuJsbn6s/+nU6cTtHnw==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pSIl9-0004bt-7H; Wed, 15 Feb 2023 09:27:47 -0500
Date: Wed, 15 Feb 2023 16:27:28 +0200
Message-Id: <83bklvatrj.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
In-Reply-To: <87ttzn2enc.fsf@HIDDEN> (message from Theodor Thornhill on
 Wed, 15 Feb 2023 15:21:11 +0100)
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
 <87ttzn2enc.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Theodor Thornhill <theo@HIDDEN>
> Cc: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
> Date: Wed, 15 Feb 2023 15:21:11 +0100
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > What happens if you indeed call treesit-node-at, as the doc string
> > suggests?
> 
> 
> int
> main
> {
>   for (;;)
> |
> 
> eval: (treesit-node-at (point)) ;; #<treesit-node ")" in 21-22>

I'm afraid I cannot interpret that.  What does it mean?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 14:21:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 09:21:19 2023
Received: from localhost ([127.0.0.1]:58361 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSIet-0004dI-62
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 09:21:19 -0500
Received: from out-156.mta1.migadu.com ([95.215.58.156]:42676)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pSIep-0004d7-8a
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 09:21:18 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1676470873;
 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=gKCLjjg60IiHlj7m4M7phldHxL82LmCSHHuy1DNBDAk=;
 b=r0/M1u79vk03dKaXzQFXzPZMB4sPo4P82Oq38HpcbkSAQNJEWaDtHIpNyzPNF9PqNwjQKQ
 ux5Z/tRE5zSRSHdMDakU5wPci8yHvZRAVGtItm0vPpiXxrZzeBiMQ7uQ98nnhjReF2ZsXi
 lJ5KZsZ+uDsmVOXazYoizAJaRYSjZyv8nG1eBoZ//K4DUvxNluVsNP8qc5pGymlHwkCOle
 /lVUyY71sUOciShV/YA6aZUnEVxdgPSBYMP8BNA31TDwJG+cRXAyuYC2gvtG5HjAA/tBT9
 FyaAuQQ+frQbjkjNUG4uoHpne/RPSoYv9SL/TCNW1Gkno3HV23UhP3PJOWs8hg==
From: Theodor Thornhill <theo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
In-Reply-To: <83lekzauvz.fsf@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN> <83lekzauvz.fsf@HIDDEN>
Date: Wed, 15 Feb 2023 15:21:11 +0100
Message-ID: <87ttzn2enc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Theodor Thornhill <theo@HIDDEN>
>> Cc: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
>> Date: Wed, 15 Feb 2023 13:41:47 +0100
>> 
>>   "Return the smallest node covering BEG to END.
>> 
>> BEWARE!  Calling this function on an empty line that is not
>> inside any top-level construct (function definition, etc.) most
>> probably will give you the root node, because the root node is
>> the smallest node that covers that empty line.  You probably want
>> to use `treesit-node-at' instead.
>> 
>> Return nil if none was found.  If NAMED is non-nil, only look for
>> named node.
>> 
>> If PARSER-OR-LANG is a parser, use that parser; if PARSER-OR-LANG
>> is a language, find the first parser for that language in the
>> current buffer, or create one if none exists; If PARSER-OR-LANG
>> is nil, try to guess the language at BEG using `treesit-language-at'."
>> 
>> 
>> Rather selecting the first node "above" point sounds more reasonable?
>
> What happens if you indeed call treesit-node-at, as the doc string
> suggests?


int
main
{
  for (;;)
|

eval: (treesit-node-at (point)) ;; #<treesit-node ")" in 21-22>

Theo





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 14:03:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 09:03:38 2023
Received: from localhost ([127.0.0.1]:58312 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSINm-00046y-Hz
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 09:03:38 -0500
Received: from eggs.gnu.org ([209.51.188.92]:38434)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pSINk-00046i-Kb
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 09:03:37 -0500
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 <eliz@HIDDEN>)
 id 1pSINe-00007x-Qm; Wed, 15 Feb 2023 09:03:30 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=byZwz5qRKP6Bs8Oh7y1ULPg9F8H7MuBoD8o9b32Ntks=; b=AtxN5MBRXvTl
 3WWWL2IxSQNvriAMjQQ6mRjEEmTc1PlC7DQf9Oz3sa618fa5AifolMzLM8wB8l4XoBt14IkrcuU/4
 RBRlkmlJxqmM9hpVmy1/DB0JcVb1WzuvCFnCvZI45P1Lci8f2UIUf1wB4NlZQduqGvlAMfmRClWfu
 Vb1w+Zcp3LHRJsymIQXQO5q+ZpDiY3UhUsgJdC5t5xKx3oF2uPM6/apgJlOnS8LcRhqEIAxLcgKPc
 rLjyBK3vVW/O6AYadaa5Hlar5V2LYscRdFQpmqAAJa8v0yLOVE1uxoNRLrX+zjAe/JDSng+ko0uvf
 DRlEXaKcO1d8p9t1MvzIsg==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pSINe-0007E0-9T; Wed, 15 Feb 2023 09:03:30 -0500
Date: Wed, 15 Feb 2023 16:03:12 +0200
Message-Id: <83lekzauvz.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
In-Reply-To: <873577qewk.fsf@HIDDEN> (message from Theodor Thornhill on
 Wed, 15 Feb 2023 13:41:47 +0100)
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Theodor Thornhill <theo@HIDDEN>
> Cc: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
> Date: Wed, 15 Feb 2023 13:41:47 +0100
> 
>   "Return the smallest node covering BEG to END.
> 
> BEWARE!  Calling this function on an empty line that is not
> inside any top-level construct (function definition, etc.) most
> probably will give you the root node, because the root node is
> the smallest node that covers that empty line.  You probably want
> to use `treesit-node-at' instead.
> 
> Return nil if none was found.  If NAMED is non-nil, only look for
> named node.
> 
> If PARSER-OR-LANG is a parser, use that parser; if PARSER-OR-LANG
> is a language, find the first parser for that language in the
> current buffer, or create one if none exists; If PARSER-OR-LANG
> is nil, try to guess the language at BEG using `treesit-language-at'."
> 
> 
> Rather selecting the first node "above" point sounds more reasonable?

What happens if you indeed call treesit-node-at, as the doc string
suggests?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 13:35:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 08:35:21 2023
Received: from localhost ([127.0.0.1]:58234 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSHwP-0000p6-Bn
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 08:35:21 -0500
Received: from mail-ed1-f45.google.com ([209.85.208.45]:42521)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1pSHwL-0000on-Vh
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 08:35:19 -0500
Received: by mail-ed1-f45.google.com with SMTP id a10so22063730edu.9
 for <61502 <at> debbugs.gnu.org>; Wed, 15 Feb 2023 05:35:17 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:from:to:cc:subject:date:message-id:reply-to;
 bh=vkbvaIsEJzNJeVn7M9jTyeExxv5NX6D3M+irGnY6sBA=;
 b=egXQDyXKQCtWrW4abgYkOruusy+MarZL/j1iIzqKDg+M2u8z6WwD3YHA6f2fmxaKmd
 U4Vf3MmJCKBjUWIz869MBkHj1k3zGctRzQGkFnsgQR1TBK7EGykRHoyq/i2rlRFMQIWW
 lVovvlVLhgSi3xeU8XIIJuxQBHK2UFPZ2WSNAX/O+Yfdgm4e1HLhOnDlpK8PCm72cfVG
 ENNZUQi69GEaUq7CSDex1MfQKpXV4KDarauU4/MyRYSIF6T/vEybxZicF3ztTUkjsexU
 1OMnmsl0reh/eIjTkhrvoI2lb2tG7hehf0xl78hAuXJMtUmALz2eUsqEqTP1GcL2DWjQ
 cWYg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=vkbvaIsEJzNJeVn7M9jTyeExxv5NX6D3M+irGnY6sBA=;
 b=5G//rAc6BjLrhM9v9Qa7TMn9ZCiRtpiyYkyDf/n5xEmDzmufglxh+IiuXENlNXo7SF
 IiLdNqGR/wGKE98+k4u5Uxb1oSVRefMahtFDGS1cH9dniHOTph07DLKWvW8ESdtiMwIs
 Uw2a+tBhhM1NHu3JNXB+YeTRdaq4BWjYDoDH8dgV9+p6qP43prs01KEysehCE3qCZx/Y
 BqFaT2xLnLW3uVk58Sylwin04WzuE6Ms8YwhiPhrKH9sNRjxbrJKtokHj21nKvY32Ag1
 knT5dsgqx0NDIwKfquDdoZLx5t9QTaExde/4ZYdK9qfYyG0/LngZfAxEFRbUD3c0yRST
 BqXw==
X-Gm-Message-State: AO0yUKXrxdHMeavyQxpQMFUatGw11nO8YRcytIowewWEEoIep5rERMVo
 Nyz/Rk86Fej8U7CrhRZSb9I=
X-Google-Smtp-Source: AK7set++ZsG3BKMl7HkTmloMor5mKw82DDzOCqzTYJEv7+70z6vCWPoxjMMqh+oOvFRNcb9Kh3ekWw==
X-Received: by 2002:a05:6402:28e:b0:4ac:d2b2:fe82 with SMTP id
 l14-20020a056402028e00b004acd2b2fe82mr2456798edv.17.1676468111932; 
 Wed, 15 Feb 2023 05:35:11 -0800 (PST)
Received: from [192.168.0.2] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id
 h11-20020a50c38b000000b004a0e2fe619esm9537002edf.39.2023.02.15.05.35.10
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 15 Feb 2023 05:35:11 -0800 (PST)
Message-ID: <6c92faac-0688-9173-798d-1a574525ca96@HIDDEN>
Date: Wed, 15 Feb 2023 15:35:09 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.4.2
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
Content-Language: en-US
To: Theodor Thornhill <theo@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
 <873577qewk.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <873577qewk.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.9 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.9 (-)

On 15/02/2023 14:41, Theodor Thornhill via Bug reports for GNU Emacs, 
the Swiss army knife of text editors wrote:
> Rather selecting the first node "above" point sounds more reasonable?

treesit-node-on is the "precise" finding function. treesit-node-at is 
the dwim-y one.

I think having treesit-node-on return a node that doesn't actually cover 
BEG to END will be very counter-intuitive.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 12:41:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 07:41:54 2023
Received: from localhost ([127.0.0.1]:58135 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSH6g-0005Gv-Jk
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 07:41:54 -0500
Received: from out-199.mta0.migadu.com ([91.218.175.199]:20827)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pSH6d-0005Gl-Js
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 07:41:52 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1676464909;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=q2pTMgc3MGE/z8Js7Hi04SLu009rjNS9fM/DvrROdbM=;
 b=wNIHruFcGCNKv0rIxWl3Ee4dg3bECA1Zt7uqfswm5l7iAz1ddP2EhfX6+OZ41gr3FtiZB8
 BbUCDa77NOtSVjWS8m5Obs8vbkRk2Nt0615ZjlIXu7KKf8S4kFhtjdpO6tj4kt3I5NJXC4
 CoZ+wNBkP/Utbwcg/plIYwQKniahxyzciYXZxZ4BA3YIH6fUl37aUkOns7m4GDobVVqokn
 K3QCzfVkvMzrlUSq6mvIb1duGCMJzUSAQaMu5EQpk7JQE1PIKxPnesJXHWtDJT7ktID6kv
 eLAGQ/6tvv3UGNQS5bKg6SQztE8xHJC2xtomEgG568f9N2vyENz9o3XAlH4/HQ==
From: Theodor Thornhill <theo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
In-Reply-To: <838rgzce0c.fsf@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN> <838rgzce0c.fsf@HIDDEN>
Date: Wed, 15 Feb 2023 13:41:47 +0100
Message-ID: <873577qewk.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Theodor Thornhill <theo@HIDDEN>
>> Cc: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
>> Date: Tue, 14 Feb 2023 21:21:33 +0100
>>=20
>> int
>> main
>> {
>>   for (;;)|
>> ```
>>=20
>> Now type RET
>>=20
>> ```
>> int
>> main
>> {
>>   for (;;)
>> |
>> ```
>>=20
>> Now type {
>>=20
>> ```
>> int
>> main
>> {
>>   for (;;)
>>     {|
>> ```
>>=20
>> Now type RET
>>=20
>> ```
>> int
>> main
>> {
>>   for (;;)
>>     {
>> |
>> ```
>>=20
>> Which is what I consider a little confusing.  We get different
>> indentation with and without the closed scope.
>
> Any idea why it doesn't choose the 'for' node?  That's what a na=C3=AFve
> user would expect, I think.

That's what any user should expect, IMO. It's due to
treesit-node-on. See its docstring:

  "Return the smallest node covering BEG to END.

BEWARE!  Calling this function on an empty line that is not
inside any top-level construct (function definition, etc.) most
probably will give you the root node, because the root node is
the smallest node that covers that empty line.  You probably want
to use `treesit-node-at' instead.

Return nil if none was found.  If NAMED is non-nil, only look for
named node.

If PARSER-OR-LANG is a parser, use that parser; if PARSER-OR-LANG
is a language, find the first parser for that language in the
current buffer, or create one if none exists; If PARSER-OR-LANG
is nil, try to guess the language at BEG using `treesit-language-at'."


Rather selecting the first node "above" point sounds more reasonable?

Theo




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 12:25:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 07:25:38 2023
Received: from localhost ([127.0.0.1]:58117 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSGqw-0002Ta-4Z
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 07:25:38 -0500
Received: from eggs.gnu.org ([209.51.188.92]:42530)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pSGqt-0002TH-Fe
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 07:25:36 -0500
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 <eliz@HIDDEN>)
 id 1pSGqo-0004Xa-1J; Wed, 15 Feb 2023 07:25:30 -0500
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=qkzPFZkrZDXUu8weTG0EHS2+EMPeaSQ51YcWWWW/7Ho=; b=oJ30OLu/i0Bk/6Y/6+BY
 6Ug+mLo03wdjVWAJeX2WJ2t0cc9hKwQtLTQPY1rEnb2FNcq7Zkm5cTGbDGgcNf67RN5gFfgIlMBaJ
 I+vubAz8dBwUvxNbIN0Vovzbl8tP4p+Fv1DB8BeieT10+Wu8ceNltt8HvUL0Q0lqKkKpwAyp/gq6G
 6dJEHW3+fLvWjGeiTK9EVZIv3HHVG+UVaqrHWC9321+71/5mDGTIoTdf4Us1eLA1URwNwKbBM1arL
 NpRpaYDLlLVYMaqLkAfZs2PBTc9a3MBvvlnORt56OdnC1bb3Zhh1Ac64LYbopWd7HO3DpLQscro92
 Yv5zJrYT9kPiqA==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pSGqY-00060O-S7; Wed, 15 Feb 2023 07:25:29 -0500
Date: Wed, 15 Feb 2023 14:24:51 +0200
Message-Id: <838rgzce0c.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
In-Reply-To: <875yc40zhu.fsf@HIDDEN> (message from Theodor Thornhill on
 Tue, 14 Feb 2023 21:21:33 +0100)
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
 <875yc40zhu.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Theodor Thornhill <theo@HIDDEN>
> Cc: pankaj@HIDDEN, casouri@HIDDEN, 61502 <at> debbugs.gnu.org
> Date: Tue, 14 Feb 2023 21:21:33 +0100
> 
> int
> main
> {
>   for (;;)|
> ```
> 
> Now type RET
> 
> ```
> int
> main
> {
>   for (;;)
> |
> ```
> 
> Now type {
> 
> ```
> int
> main
> {
>   for (;;)
>     {|
> ```
> 
> Now type RET
> 
> ```
> int
> main
> {
>   for (;;)
>     {
> |
> ```
> 
> Which is what I consider a little confusing.  We get different
> indentation with and without the closed scope.

Any idea why it doesn't choose the 'for' node?  That's what a na´ve
user would expect, I think.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 06:08:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 15 01:08:17 2023
Received: from localhost ([127.0.0.1]:57610 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSAxk-00009V-Pe
	for submit <at> debbugs.gnu.org; Wed, 15 Feb 2023 01:08:17 -0500
Received: from out-86.mta1.migadu.com ([95.215.58.86]:56130)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pSAxh-00009J-1a
 for 61502 <at> debbugs.gnu.org; Wed, 15 Feb 2023 01:08:15 -0500
Date: Wed, 15 Feb 2023 07:07:59 +0100
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1676441290;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=35YQYnshj8imVg/EYIvgudWvgCOGaQ+uH+hHbbN/zu8=;
 b=P7Ir/q4zz315ZNtxAxTdvOKR/FHxfsxzv++mrdPRuSnU2BlniUBzGatG+VxC1Je7HLmkTo
 NSpJnaTuxWm1u7aVOsChwl1ZTN5I7N3tYGS68SSANelmxy/nPbhVDzzk84aoibh5c6MQ18
 4gjinnDNmuk4c5TYhPRu1lQXSS7rcn0yL0TbA/ylbMpdvMK3Q0y0Kqivo6FO0jqWTdqF5g
 3GIxP0SD7COgrIZl32rV+kU/y+g7x1shIVg3J4nYP+GdkbJX3uw6hfcRZ73jl4n1oABExy
 049pDcFrf0DJEd8zkXGpdsw+Xwbt41pb5/YUgoQaUPAk10uB5MUv20T2mwwqYw==
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 Pankaj Jangid <pankaj@HIDDEN>, Yuan Fu <casouri@HIDDEN>
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
In-Reply-To: <67e055d8-c709-df09-374e-560057f61731@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN>
 <67e055d8-c709-df09-374e-560057f61731@HIDDEN>
Message-ID: <B4DA2392-C74E-49D7-B2F4-77E672C3FFDE@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



On 15 February 2023 00:57:17 CET, Dmitry Gutov <dgutov@yandex=2Eru> wrote:
>On 14/02/2023 21:41, Theodor Thornhill via Bug reports for GNU Emacs, the=
 Swiss army knife of text editors wrote:
>> What do you think?
>>=20
>> Theo
>>=20
>>=20
>> diff --git a/lisp/treesit=2Eel b/lisp/treesit=2Eel
>> index 749781894b=2E=2E300a703515 100644
>> --- a/lisp/treesit=2Eel
>> +++ b/lisp/treesit=2Eel
>> @@ -1418,6 +1418,8 @@ treesit--indent-1
>>            ;; encompass the whitespace=2E
>>            (parent (cond ((and node parser)
>>                           (treesit-node-parent node))
>> +                       ((equal (treesit-node-type smallest-node) "}")
>> +                        (treesit-node-parent smallest-node))
>>                          (t (treesit-node-on bol bol)))))
>>         (funcall treesit-indent-function node parent bol))))
>
>Here's a counter-example for this patch:
>
>int
>main ()
>{}|
>
>press RET at |, and you'll see the next line indented by 2 spaces=2E Wher=
eas it shouldn't=2E This happens, among other things, because the added cod=
e doesn't distinguish between "real" and "virtual" nodes=2E
>
>BTW, in this example:
>
>int
>main
>{
>  for (;;)
>    {|
>}
>
>the "}" node selected by treesit--indent-1 is not "unexisting": it select=
s the closer on the next line, which is parsed to be the part of the "for" =
node=2E Thanks to its presence, the parent compound_statement node contains=
 the point, and everything works out=2E
>
>And this one
>
>int
>main
>{
>  for (;;)|
>}
>
>isn't fixed with your patch because the "unexisting" node in place is a d=
ifferent one: "expression_statement", and it has no closers=2E And it's "vi=
rtually" placed at the end of the previous line by the parser=2E
>
>So in most cases if the user has electric-pair-mode on, indentation shoul=
d work okay=2E Without a pairing solution, though, we see different grammar=
s handling incomplete code in different ways for different syntactic elemen=
ts: virtual nodes, container nodes that span after point, container nodes t=
hat don't span after point, statements that parse into a different node typ=
e (usually wrapped in ERROR)=2E We could report these one by one, hoping fo=
r the best=2E I'm curious how different editors fare with indentation in th=
ese conditions -- perhaps they use a different, more error-proof approach=
=2E But it could be that their uses are less fussy about indentation than w=
e are=2E

Sure, i agree - the patch was not a change request, merely an example to s=
how why the root node was chosen rather than the closer compound_statement =
node=2E




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 15 Feb 2023 00:12:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 14 19:12:35 2023
Received: from localhost ([127.0.0.1]:57396 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pS5PX-0007TV-Am
	for submit <at> debbugs.gnu.org; Tue, 14 Feb 2023 19:12:35 -0500
Received: from mail-ej1-f48.google.com ([209.85.218.48]:39904)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1pS5PV-0007TJ-Pu
 for 61502 <at> debbugs.gnu.org; Tue, 14 Feb 2023 19:12:34 -0500
Received: by mail-ej1-f48.google.com with SMTP id jg8so44233075ejc.6
 for <61502 <at> debbugs.gnu.org>; Tue, 14 Feb 2023 16:12:33 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:from:to:cc:subject:date:message-id:reply-to;
 bh=1/RL5nvsCibVC9XlfsQDA5eRONS4uY2QjTTdIVrVaeU=;
 b=FXk4R8y0IPocnBLF4gzPan2f/jZg/bbTqRwnR7Xvyp/w7e7+NqvnMoUq82qMneykjN
 dI26TS8lC953ovCRDhKrBXET3nz6ehJInJlNF/hjxTEBSlO4gAkKJhbxymCGd8yXRFt3
 61m7CtZroaWtTL4hhUAbf5TVHS1nSlPFautwDckOV/CQNQx9cCBi7O1OyTwvms2/J3z7
 FddNWu+SIUidEOALR+Md0HDz57Wiqu0PY4fMiowWmAszdrOagR6HyCAtxPog6Ps15qJs
 Aour6y7JAYL2s4sFZZAtvLlmXsXJvCks3qiRa8DIoPAbn2JW+c3IwWATWqpN1dQrLNVg
 t8xA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=1/RL5nvsCibVC9XlfsQDA5eRONS4uY2QjTTdIVrVaeU=;
 b=pkmieY5cBt5by2vGexoKyJxCvpJ6IKSuDZ4+1bAoKdtsv9whhkg+pfyKpX4jRBJvqJ
 KFUOJBTYIZiO+IF8rD26Y5eyGvVUyadTM8g2yylr21vFU2kYbrKFRAaEOjhUtCIejIPZ
 31OjSb7t+cMy7Kwx4HFg+MWxGOe5bgLgD32SiENunYcPLXBSW9FcdC0XkeJv9W93ruI5
 I6MXVtTMbdscZm8ytSH1q/PgS6J9u9D1i2OxUNtoYilxW0N7DTNQr7xPSG/TOYAmrFHN
 LLtp6B7jHurMqbgKg94EdurKlHURyUBuUrZpjH6t1J8IsF6DiIzMKrXX9pIm4atwmEcq
 BVaA==
X-Gm-Message-State: AO0yUKUd1NpVGltutIIh3pGgi0Ivkq7INpSmhIjNxcovEksPcSGgMINP
 tIHxjKumXQ/6v6bI2KvJSJ8=
X-Google-Smtp-Source: AK7set+CpGt4WRGrlPIzReb6qTfpt9UT9zfs3MixQDFNKNuOCIFUBp2jNd2mOivhINuO5by7LK+AAw==
X-Received: by 2002:a17:906:6944:b0:87a:6a63:9014 with SMTP id
 c4-20020a170906694400b0087a6a639014mr343277ejs.20.1676419947665; 
 Tue, 14 Feb 2023 16:12:27 -0800 (PST)
Received: from [192.168.0.2] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id
 g22-20020a17090670d600b008b0ff9c1ea8sm4533071ejk.56.2023.02.14.16.12.24
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 14 Feb 2023 16:12:25 -0800 (PST)
Message-ID: <9450d97c-aae8-21c6-8a15-b7608b8b2b3e@HIDDEN>
Date: Wed, 15 Feb 2023 02:12:23 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.4.2
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
Content-Language: en-US
To: Theodor Thornhill <theo@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 Pankaj Jangid <pankaj@HIDDEN>, Yuan Fu <casouri@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN>
 <7152d115-64b0-59e3-ddc5-c0132c1f089f@HIDDEN>
 <F6AC433C-54FB-4717-8996-C2A7245EE119@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <F6AC433C-54FB-4717-8996-C2A7245EE119@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.9 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.9 (-)

On 14/02/2023 23:00, Theodor Thornhill via Bug reports for GNU Emacs, 
the Swiss army knife of text editors wrote:
> 
> On 14 February 2023 21:59:03 CET, Dmitry Gutov<dgutov@HIDDEN>  wrote:
>> On 14/02/2023 21:41, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote:
>>> diff --git a/lisp/treesit.el b/lisp/treesit.el
>>> index 749781894b..300a703515 100644
>>> --- a/lisp/treesit.el
>>> +++ b/lisp/treesit.el
>>> @@ -1418,6 +1418,8 @@ treesit--indent-1
>>>             ;; encompass the whitespace.
>>>             (parent (cond ((and node parser)
>>>                            (treesit-node-parent node))
>>> +                       ((equal (treesit-node-type smallest-node) "}")
>>> +                        (treesit-node-parent smallest-node))
>>>                           (t (treesit-node-on bol bol)))))
>>>          (funcall treesit-indent-function node parent bol))))
>> Is it a good idea to add C-specific constants to generic code?
>>
>> Other modes might not have a node called "}" at all.
> Yeah this was merely an example. There may be some "block-ender" concept one could envision. I need to experiment with it, and it may not be feasible at all

I was thinking we could use a more/grammar-specific override to choose 
which node to use to base the indentation on.

I.e. being able to override this piece of logic:

                (treesit-parent-while
                 smallest-node
                 (lambda (node)
                   (and (eq bol (treesit-node-start node))
                        (not (treesit-node-eq node root)))))

It could also help with issues like 
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60602#8, to avoid 
duplication in indentation rules.

AFAICT this is largely possible to do already by changing 
treesit-indent-function to some mode-specific wrapper, but an override 
like the above could be written more succinctly.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 14 Feb 2023 23:57:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 14 18:57:27 2023
Received: from localhost ([127.0.0.1]:57377 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pS5At-000740-F1
	for submit <at> debbugs.gnu.org; Tue, 14 Feb 2023 18:57:27 -0500
Received: from mail-ed1-f51.google.com ([209.85.208.51]:40907)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1pS5Ar-00073n-UE
 for 61502 <at> debbugs.gnu.org; Tue, 14 Feb 2023 18:57:26 -0500
Received: by mail-ed1-f51.google.com with SMTP id fi26so19730889edb.7
 for <61502 <at> debbugs.gnu.org>; Tue, 14 Feb 2023 15:57:25 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:from:to:cc:subject:date:message-id:reply-to;
 bh=alePXNvu11SXmuGhl9sabsY4djTX2zKHUes2oyfLSUg=;
 b=FrF1JRUZwrxYYKU2yqCKTqFzJ5tGzNAwRRd9SWtHRSYpBV3YKPbBOdq/l+edwJ9QiJ
 1uy/4Ti02mOF1Wlc3I32YbebDhCpeMK9OSdj9k2H9qCXch9Oh9PhW8YOP7r3naRBlLYI
 0cxdxm30+Xf6Tt+JxnNXHluuRCIsgJmzbff/f7eNWK0QhPPahOcR7pMmuPcoDHIiAM+1
 EWh+1+8cCo0lgO7a6FOvdT0SeKHVX3nmXWykDcwtmB1IicLXC1hXv8xFWgUaReTEF5fm
 s6S0YovM9SZ+VGY6YqRdoL9R4OntdTzh1OD7OEtIvLXTguS2pK+CAGb0bCv6a6hAnIkL
 tJMQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=alePXNvu11SXmuGhl9sabsY4djTX2zKHUes2oyfLSUg=;
 b=OhcJYiAdzSv/q/2YC8M/usp5g5Y/GxQzkLfaqPqC8KpiokEpnpNdmL5frk07/iG+HW
 ddLz5fEfKwmXgZ++cs6SiG9Izoy8o/7nz3HjLlsZ+kEgswvA2vMhHMgQ4+m/0vR4J31d
 phn2Vlp5nLNzW+GFsYzj2b+JdxTnJYr6/zaV6v35bA3DWWHVOh6XZ1X/6iCNHvNje1XQ
 +WwGxbMV8rAC+jxOKCnkcFlQ74HkW07dwrclbS/yae+IpN4ofLZisOr4zpkQAFyQEhsN
 UiduhJww0ekmf0S4Ig2dQL93njqfBZB8YiHpc60DJOkcvNukYId7Opd0UBtZzSx63Lkl
 LkDQ==
X-Gm-Message-State: AO0yUKX8SnGW79YocfKDVx46Le8fDsiPamq3t63o3W/ANkL65vJdIXPj
 4CSMUUNNUQV6JqDnIXtkhrI=
X-Google-Smtp-Source: AK7set865T1DoE6eg7hawMrSe1d5vtJSA5F6RHFKoj607vAqa15skycE37WlLpW1JUF/CQlFE+dYjg==
X-Received: by 2002:aa7:c2c9:0:b0:4ac:bf55:7d61 with SMTP id
 m9-20020aa7c2c9000000b004acbf557d61mr103724edp.9.1676419039819; 
 Tue, 14 Feb 2023 15:57:19 -0800 (PST)
Received: from [192.168.0.2] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id
 y4-20020a50ce04000000b004a27046b7a7sm8742764edi.73.2023.02.14.15.57.18
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 14 Feb 2023 15:57:19 -0800 (PST)
Message-ID: <67e055d8-c709-df09-374e-560057f61731@HIDDEN>
Date: Wed, 15 Feb 2023 01:57:17 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.4.2
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
Content-Language: en-US
To: Theodor Thornhill <theo@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 Pankaj Jangid <pankaj@HIDDEN>, Yuan Fu <casouri@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <87edqs11db.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.9 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.9 (-)

On 14/02/2023 21:41, Theodor Thornhill via Bug reports for GNU Emacs, 
the Swiss army knife of text editors wrote:
> What do you think?
> 
> Theo
> 
> 
> diff --git a/lisp/treesit.el b/lisp/treesit.el
> index 749781894b..300a703515 100644
> --- a/lisp/treesit.el
> +++ b/lisp/treesit.el
> @@ -1418,6 +1418,8 @@ treesit--indent-1
>            ;; encompass the whitespace.
>            (parent (cond ((and node parser)
>                           (treesit-node-parent node))
> +                       ((equal (treesit-node-type smallest-node) "}")
> +                        (treesit-node-parent smallest-node))
>                          (t (treesit-node-on bol bol)))))
>         (funcall treesit-indent-function node parent bol))))

Here's a counter-example for this patch:

int
main ()
{}|

press RET at |, and you'll see the next line indented by 2 spaces. 
Whereas it shouldn't. This happens, among other things, because the 
added code doesn't distinguish between "real" and "virtual" nodes.

BTW, in this example:

int
main
{
   for (;;)
     {|
}

the "}" node selected by treesit--indent-1 is not "unexisting": it 
selects the closer on the next line, which is parsed to be the part of 
the "for" node. Thanks to its presence, the parent compound_statement 
node contains the point, and everything works out.

And this one

int
main
{
   for (;;)|
}

isn't fixed with your patch because the "unexisting" node in place is a 
different one: "expression_statement", and it has no closers. And it's 
"virtually" placed at the end of the previous line by the parser.

So in most cases if the user has electric-pair-mode on, indentation 
should work okay. Without a pairing solution, though, we see different 
grammars handling incomplete code in different ways for different 
syntactic elements: virtual nodes, container nodes that span after 
point, container nodes that don't span after point, statements that 
parse into a different node type (usually wrapped in ERROR). We could 
report these one by one, hoping for the best. I'm curious how different 
editors fare with indentation in these conditions -- perhaps they use a 
different, more error-proof approach. But it could be that their uses 
are less fussy about indentation than we are.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 14 Feb 2023 21:00:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 14 16:00:48 2023
Received: from localhost ([127.0.0.1]:57152 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pS2Pw-0003kR-CP
	for submit <at> debbugs.gnu.org; Tue, 14 Feb 2023 16:00:48 -0500
Received: from out-205.mta0.migadu.com ([91.218.175.205]:36146)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pS2Pt-0003kF-Oa
 for 61502 <at> debbugs.gnu.org; Tue, 14 Feb 2023 16:00:46 -0500
Date: Tue, 14 Feb 2023 22:00:41 +0100
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1676408444;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=lExgkRLGNpT6KOJVsyhtz/CbqGfGISph2o6z8GVR+SE=;
 b=tqv1+b3/eWy9qGgAWHC78ya5sM4cPle8nEJdgcVATjO/OGAGQD1qQ4bKRw+KPoDvPPpPZ5
 1lgcYkwXVpu4aDFFHBAJbhhRd4Mg7kuKhuBAwpwJjFvz2EEW1UdDqHq/rinFR//CCayZbA
 Ls7TLfRNn4SjxzsacGrhCpryr6z6crV+DvV1dRJweDJ+CW3NbkXaQKQaabmv4byuKMuAUQ
 8EAPTbbMhud8EG0QF6z1GNKqA3GljffYQaeg8hzCPLdxZe7rjDOnE1ytXG0tuNjf1v2JIN
 nQws9i1WvImyabFcmmNXPNHuBmyi2ehU6fc/FLQTHPNzFs3YZX+oLSGn/wgXag==
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Theodor Thornhill <theo@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 Pankaj Jangid <pankaj@HIDDEN>, Yuan Fu <casouri@HIDDEN>
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
In-Reply-To: <7152d115-64b0-59e3-ddc5-c0132c1f089f@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN>
 <7152d115-64b0-59e3-ddc5-c0132c1f089f@HIDDEN>
Message-ID: <F6AC433C-54FB-4717-8996-C2A7245EE119@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



On 14 February 2023 21:59:03 CET, Dmitry Gutov <dgutov@yandex=2Eru> wrote:
>On 14/02/2023 21:41, Theodor Thornhill via Bug reports for GNU Emacs, the=
 Swiss army knife of text editors wrote:
>> diff --git a/lisp/treesit=2Eel b/lisp/treesit=2Eel
>> index 749781894b=2E=2E300a703515 100644
>> --- a/lisp/treesit=2Eel
>> +++ b/lisp/treesit=2Eel
>> @@ -1418,6 +1418,8 @@ treesit--indent-1
>>            ;; encompass the whitespace=2E
>>            (parent (cond ((and node parser)
>>                           (treesit-node-parent node))
>> +                       ((equal (treesit-node-type smallest-node) "}")
>> +                        (treesit-node-parent smallest-node))
>>                          (t (treesit-node-on bol bol)))))
>>         (funcall treesit-indent-function node parent bol))))
>
>Is it a good idea to add C-specific constants to generic code?
>
>Other modes might not have a node called "}" at all=2E

Yeah this was merely an example=2E There may be some "block-ender" concept=
 one could envision=2E I need to experiment with it, and it may not be feas=
ible at all

Theo 




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 14 Feb 2023 20:59:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 14 15:59:15 2023
Received: from localhost ([127.0.0.1]:57147 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pS2OQ-0003g9-TZ
	for submit <at> debbugs.gnu.org; Tue, 14 Feb 2023 15:59:15 -0500
Received: from mail-wm1-f41.google.com ([209.85.128.41]:54915)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1pS2OP-0003fw-31
 for 61502 <at> debbugs.gnu.org; Tue, 14 Feb 2023 15:59:13 -0500
Received: by mail-wm1-f41.google.com with SMTP id n13so11878369wmr.4
 for <61502 <at> debbugs.gnu.org>; Tue, 14 Feb 2023 12:59:13 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:from:to:cc:subject:date:message-id:reply-to;
 bh=qdqlm8aF+6DCVb6bT3Ya7ipO5wk53NPTjU5+x2aiUpI=;
 b=kQ6R7iWrqxgyfHC2wrdMOhXBFXVzjbIL8xEnQBavJPo9Mi9pYes5+gGibb9GERKtgJ
 VHe6FXndZQY0IDulMp6B3MpXnubUNlCAAtdbXYHhn2bphplG5zvb37CyNlb/IdDjaZKL
 StnkTzplUpwWepgvu8nh/wnj47PzzxlQDDpgCPm6cR5VtbttMO5TFt3+hYOzG4iTX650
 b2WCC6mQmzEyXoDXDYZMvcf2+tPEvc8llOk4x7OmP/8H6Eryk85/7tTgljbpioRzmayU
 Z/N70TYUCfnOSV4qtWvVLrwpiIXeSIqKrlXsonxRxKmCeuFy+mwzyOHYTjhOfAhZUVaz
 qV4Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=qdqlm8aF+6DCVb6bT3Ya7ipO5wk53NPTjU5+x2aiUpI=;
 b=a5MwrtfBfATLPtMDi1AJmIhI9qDO4EywfnYXaiq+SUhbrKR9hrb48MAlG5ZMpsRRTX
 wozJSjPm3gG9P88ECPQa3QkgYoY6Rp3ZsQf8VZaZDzuDwn5nAvev6IlI3JGs+9Q5Q09+
 GSZ9GB3YC+LwHMoIVru6v0NLosyrnHiVsNvbjEZXUaeEjD5HvCioTjp5A2rhwpkRU9Wu
 BRNnNOIKiTj6/9tFCAkPwbbxmpz+djU8uAhfPdfPWMq4Qp8oTMZiSYDlIDstDOCcycy3
 DFT3HGwRPdzzgR3LK9yLNWJgjo2QTNygm3mgD4YVmwmhQpLv39Jmx4ZO1/AwNV5/a4uB
 c/1g==
X-Gm-Message-State: AO0yUKXxlwshMqQNb7Ze8HG3K6f/XiwhsjzSmh3101Yv5upPshbymHgh
 FYvlJG/VNb1V6CO1Ctry+Js=
X-Google-Smtp-Source: AK7set84Z6o9RIS5P1mQbV4Ho70Q6DshJBFQJQKqPWTRTZ2tgJUpGJHZqe3AHNjeFvcoAB/mSB6HTQ==
X-Received: by 2002:a05:600c:3094:b0:3df:ed95:d757 with SMTP id
 g20-20020a05600c309400b003dfed95d757mr137056wmn.34.1676408347049; 
 Tue, 14 Feb 2023 12:59:07 -0800 (PST)
Received: from [192.168.0.2] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id
 b39-20020a05600c4aa700b003dc433bb5e1sm17898648wmp.9.2023.02.14.12.59.04
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 14 Feb 2023 12:59:06 -0800 (PST)
Message-ID: <7152d115-64b0-59e3-ddc5-c0132c1f089f@HIDDEN>
Date: Tue, 14 Feb 2023 22:59:03 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.4.2
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
Content-Language: en-US
To: Theodor Thornhill <theo@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 Pankaj Jangid <pankaj@HIDDEN>, Yuan Fu <casouri@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <87edqs11db.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.9 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.9 (-)

On 14/02/2023 21:41, Theodor Thornhill via Bug reports for GNU Emacs, 
the Swiss army knife of text editors wrote:
> diff --git a/lisp/treesit.el b/lisp/treesit.el
> index 749781894b..300a703515 100644
> --- a/lisp/treesit.el
> +++ b/lisp/treesit.el
> @@ -1418,6 +1418,8 @@ treesit--indent-1
>            ;; encompass the whitespace.
>            (parent (cond ((and node parser)
>                           (treesit-node-parent node))
> +                       ((equal (treesit-node-type smallest-node) "}")
> +                        (treesit-node-parent smallest-node))
>                          (t (treesit-node-on bol bol)))))
>         (funcall treesit-indent-function node parent bol))))

Is it a good idea to add C-specific constants to generic code?

Other modes might not have a node called "}" at all.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 14 Feb 2023 20:21:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 14 15:21:39 2023
Received: from localhost ([127.0.0.1]:57108 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pS1o3-0002dP-3Q
	for submit <at> debbugs.gnu.org; Tue, 14 Feb 2023 15:21:39 -0500
Received: from out-111.mta1.migadu.com ([95.215.58.111]:36852)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pS1o0-0002dE-O8
 for 61502 <at> debbugs.gnu.org; Tue, 14 Feb 2023 15:21:38 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1676406095;
 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=WZA+RzEgvPyvD5w+4IMWGCQ1uC+gaODhQE1i8yl7Ouw=;
 b=WB21VrFca0rEFrrhqfQNpqge3FJAsaptJominPmAqbaHjtuMgHN88GV8NYuTbKZsWpZnvY
 6xrrFkAH21dAX7bgkCa7LPS+v0hM4+qsa34K9nuGZCFFlhWghooNlACJrab7kVZ+kHN+wA
 GXlCKaWORFjoHOHm1SV+XLTQlCvG85S5XAoI/U4hk6EsrOZ/b4NYX6Sv3bOYd5U6D93IUC
 o4MI1wQCQgZKbu3l5U5kc5ygrw2AYZgpJ0VpJgmcpBEn41YiAoribhqAytTal3GqofkUfz
 iRU6uJvAgRxYfFnLq3C/s88/WibUq0zyx6Y5q3Z3CmHn9nI1sSKYHRbZPjrQJA==
From: Theodor Thornhill <theo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
In-Reply-To: <83a61gc8xx.fsf@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN> <83a61gc8xx.fsf@HIDDEN>
Date: Tue, 14 Feb 2023 21:21:33 +0100
Message-ID: <875yc40zhu.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Theodor Thornhill <theo@HIDDEN>
>> Cc: 61502 <at> debbugs.gnu.org
>> Date: Tue, 14 Feb 2023 20:41:04 +0100
>> 
>> Eli Zaretskii <eliz@HIDDEN> writes:
>> 
>> > Keep typing whatever code you wan "int main" to include, and it will
>> > auto-indent soon enough.
>> 
>> Yeah, but.
>
> My point is that what we are used to from CC mode does not necessarily
> have to work the same way with tree-sitter based modes.  As long as
> the indentation fixes itself soon enough, we are still fine, I think.
>
>> int
>> main
>> {
>>   for (;;)
>>     {|
>> }
>> ```
>> 
>> If you press RET if point at | you'll see we indent immediately, even
>> though there is no closing bracket.  This is because of how
>> treesit-indent defaults to treesit-node-on when there is no node at
>> point.  So in the example without the for loop the parent is then set to
>> whatever treesit-node-on returns, which in this case is the root
>> node. That means that the rule for translation_unit is selected, which
>> is:
>> 
>>          `(((parent-is "translation_unit") point-min 0)
>> 
>> However, what's interesting here is that treesit-indent selects an
>> "unexisting" node as the "smallest-node".  Specifically that is:
>> 
>>          #<treesit-node "}" in 13-13>
>> 
>> This node in turn will return "compound_statement" if you look for its
>> parent.  It seems some parsers detects these nodes, so maybe we should
>> add some handling for that?  Some "block-closers" code in
>> treesit-node-on, so that treesit-node-on doesn't default to the root
>> node, but rather the compound_statement?
>
> AFAIU, you are talking about hitting RET in the following situation
> (where "|" stands for point):
>
> int main ()
> {|
> }
>
> However, the OP presented a slightly different situation:
>
> int main ()
> {|
>
> That is, without the closing brace.  In that case, there's no "}" in
> the source.  Are you saying that the tree-sitter's parser "invents"
> such a node?

That's correct. In tree-sitter-c at least that's the case.

>
> And why does treesit-indent select that "unexisting" node in the first
> place?
>

This code:

         (smallest-node
          (cond ((null (treesit-parser-list)) nil)
                ((eq 1 (length (treesit-parser-list)))
                 (treesit-node-at bol))
                ((treesit-language-at (point))
                 (treesit-node-at bol (treesit-language-at (point))))
                (t (treesit-node-at bol))))

treesit-node-at selects the "invented" node.

>> I'm not sure this explanation was easy to follow at all, but I'll add a
>> hack in a diff to make the point hopefully a little clearer.
>> 
>> What do you think?
>
> How well did you test that?

Not well at all.  I just created that hack to make the example a little
clearer.  I think the change probably should go into treesit-node-on.

> Does it fix similar problems with struct
> definition at top-level?  Are there any regressions elsewhere in the
> indentation?

Not that I found, but I'll experiment some more.

>
> There are also other similar cases, but with code on deeper levels.
> Try this, for example (where "|" again stands for point):
>
> int
> main
> {
>   for (;;)|
> }
>
> Now press RET and observe the result:
>
> int
> main
> {
>   for (;;)
>   |
> }
>
> instead of the expected
>
> int
> main
> {
>   for (;;)
>     |
> }
>
> Why?

If I'm not mistaken the same "problem". Treesit-node-on selects the
surrounding compound_statement, so it only indents one step from column 0.

>
> (Of course, as soon as you type ";", the code is automatically
> reindented to yield the correct indentation.  Which was my point.)

Yeah, but consider the same example of yours without the closing brace:

```
int
main
{
  for (;;)|
```

Now type RET

```
int
main
{
  for (;;)
|
```

Now type {

```
int
main
{
  for (;;)
    {|
```

Now type RET

```
int
main
{
  for (;;)
    {
|
```

Which is what I consider a little confusing.  We get different
indentation with and without the closed scope.

Theo




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 14 Feb 2023 20:02:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 14 15:02:31 2023
Received: from localhost ([127.0.0.1]:57102 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pS1VX-0002B7-3A
	for submit <at> debbugs.gnu.org; Tue, 14 Feb 2023 15:02:31 -0500
Received: from eggs.gnu.org ([209.51.188.92]:57496)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pS1VV-0002Au-R6
 for 61502 <at> debbugs.gnu.org; Tue, 14 Feb 2023 15:02:30 -0500
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 <eliz@HIDDEN>)
 id 1pS1VQ-00073o-2x; Tue, 14 Feb 2023 15:02:24 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=+niTG6cewamdl9KyIZt55PHoUsI6zeQcMwjhpG3guCU=; b=ojkV2ssvcnZB
 YdRZIaRx3JJKRVvhUtm8A3CB+yu51vrqqo6l3wVcjvMDormjiaOwh0N/sUX7gjRgl/PSO8bIMgawN
 zw6Rn84xo0vit8upzYS71UgEtCS84sdFukervGgXoHWOd6lJwM9LrFij+YxBg3tQLosQpb5bCBx02
 xiihxa4ToYyCZd+DBeenZFxNJN1bDhjztRuN+mZfn4mAtav8H38ZoDWHoRyp7mYTBjQjQSLaT0PzP
 4kp5vhNbROpogaIG+qEz5JBs0NYbZqXZfzQ0DKucYApwM0AYO2flg9BVx1N53d3vhLBGBzSgL0HtB
 59kOiriyypUUIKYXYeomNw==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pS1VP-0008Ge-DW; Tue, 14 Feb 2023 15:02:23 -0500
Date: Tue, 14 Feb 2023 22:02:02 +0200
Message-Id: <83a61gc8xx.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Theodor Thornhill <theo@HIDDEN>
In-Reply-To: <87edqs11db.fsf@HIDDEN> (message from Theodor Thornhill on
 Tue, 14 Feb 2023 20:41:04 +0100)
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
 <87edqs11db.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org, casouri@HIDDEN, pankaj@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Theodor Thornhill <theo@HIDDEN>
> Cc: 61502 <at> debbugs.gnu.org
> Date: Tue, 14 Feb 2023 20:41:04 +0100
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > Keep typing whatever code you wan "int main" to include, and it will
> > auto-indent soon enough.
> 
> Yeah, but.

My point is that what we are used to from CC mode does not necessarily
have to work the same way with tree-sitter based modes.  As long as
the indentation fixes itself soon enough, we are still fine, I think.

> int
> main
> {
>   for (;;)
>     {|
> }
> ```
> 
> If you press RET if point at | you'll see we indent immediately, even
> though there is no closing bracket.  This is because of how
> treesit-indent defaults to treesit-node-on when there is no node at
> point.  So in the example without the for loop the parent is then set to
> whatever treesit-node-on returns, which in this case is the root
> node. That means that the rule for translation_unit is selected, which
> is:
> 
>          `(((parent-is "translation_unit") point-min 0)
> 
> However, what's interesting here is that treesit-indent selects an
> "unexisting" node as the "smallest-node".  Specifically that is:
> 
>          #<treesit-node "}" in 13-13>
> 
> This node in turn will return "compound_statement" if you look for its
> parent.  It seems some parsers detects these nodes, so maybe we should
> add some handling for that?  Some "block-closers" code in
> treesit-node-on, so that treesit-node-on doesn't default to the root
> node, but rather the compound_statement?

AFAIU, you are talking about hitting RET in the following situation
(where "|" stands for point):

int main ()
{|
}

However, the OP presented a slightly different situation:

int main ()
{|

That is, without the closing brace.  In that case, there's no "}" in
the source.  Are you saying that the tree-sitter's parser "invents"
such a node?

And why does treesit-indent select that "unexisting" node in the first
place?

> I'm not sure this explanation was easy to follow at all, but I'll add a
> hack in a diff to make the point hopefully a little clearer.
> 
> What do you think?

How well did you test that?  Does it fix similar problems with struct
definition at top-level?  Are there any regressions elsewhere in the
indentation?

There are also other similar cases, but with code on deeper levels.
Try this, for example (where "|" again stands for point):

int
main
{
  for (;;)|
}

Now press RET and observe the result:

int
main
{
  for (;;)
  |
}

instead of the expected

int
main
{
  for (;;)
    |
}

Why?

(Of course, as soon as you type ";", the code is automatically
reindented to yield the correct indentation.  Which was my point.)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 14 Feb 2023 19:41:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 14 14:41:11 2023
Received: from localhost ([127.0.0.1]:57063 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pS1At-0005Hg-F7
	for submit <at> debbugs.gnu.org; Tue, 14 Feb 2023 14:41:11 -0500
Received: from out-7.mta0.migadu.com ([91.218.175.7]:62252)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <theo@HIDDEN>) id 1pS1Ap-0005HW-KV
 for 61502 <at> debbugs.gnu.org; Tue, 14 Feb 2023 14:41:10 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no;
 s=key1; t=1676403665;
 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=6JJjV+R71alHM0Z7NBxmFWkLcLCZleeMYscWSoc7UJo=;
 b=vci9ITJ3+uJJRL6JlE1ZFAtDTEd6sVfm9o193QVoRRfCJogN/iUJHMtvWGZ6XvEMjeUbhe
 C4P3hQam4nSEafZXT34vLjtpPKa80f7uwe8ZV+oP2N7VgPLky0nZbBD6t9bj3/fg279Qh9
 PLaR9eqImust7dIY94utDJBuOkDNbwdUXaz+nMlx241Xoh+p5dsl8AMyxqGXXKO/v7uROt
 PEMXKytUzzDS3QS+EO93TwmuO0+/SbSKaMQK/ZFbtnI3YacCIyuG+2/WOpUQYPCGKCBGbO
 IICRr3iFClvstcCbYXrB4U6WEPX9Tbma4QFQ8Dp8EN9+VSS7X8zvaVY8epjqug==
From: Theodor Thornhill <theo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>, Pankaj Jangid <pankaj@HIDDEN>,
 Yuan Fu <casouri@HIDDEN>
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
In-Reply-To: <83a61ge69s.fsf@HIDDEN>
References: <87v8k4g8xu.fsf@HIDDEN> <83a61ge69s.fsf@HIDDEN>
Date: Tue, 14 Feb 2023 20:41:04 +0100
Message-ID: <87edqs11db.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Pankaj Jangid <pankaj@HIDDEN>
>> Date: Tue, 14 Feb 2023 10:06:13 +0530
>> 
>> 
>> The auto-indent is not working when using c-ts-mode.
>> 
>> Steps:
>> 
>> 1. create a new file test.c
>> 
>> 2. After typing following snippet, the indentation should work
>> automatically on RET. But even the TAB is not indenting the next line
>> (after the RET),
>> 
>> --8<---------------cut here---------------start------------->8---
>> int main()
>> {
>> --8<---------------cut here---------------end--------------->8---
>
> Keep typing whatever code you wan "int main" to include, and it will
> auto-indent soon enough.

Yeah, but.

>
> So I'm not sure your expectations are necessarily true; they could be
> just something you are used to in CC mode.  But I'll let Yuan and Theo
> chime in and tell whether a single RET here is supposed to
> auto-indent.  Does c-ts-mode really always reindents on RET?

I agree this is a little unexpected. Let's consider this code:

```
int
main
{
  for (;;)
    {|
}
```

If you press RET if point at | you'll see we indent immediately, even
though there is no closing bracket.  This is because of how
treesit-indent defaults to treesit-node-on when there is no node at
point.  So in the example without the for loop the parent is then set to
whatever treesit-node-on returns, which in this case is the root
node. That means that the rule for translation_unit is selected, which
is:

         `(((parent-is "translation_unit") point-min 0)

However, what's interesting here is that treesit-indent selects an
"unexisting" node as the "smallest-node".  Specifically that is:

         #<treesit-node "}" in 13-13>

This node in turn will return "compound_statement" if you look for its
parent.  It seems some parsers detects these nodes, so maybe we should
add some handling for that?  Some "block-closers" code in
treesit-node-on, so that treesit-node-on doesn't default to the root
node, but rather the compound_statement?

I'm not sure this explanation was easy to follow at all, but I'll add a
hack in a diff to make the point hopefully a little clearer.


What do you think?

Theo


diff --git a/lisp/treesit.el b/lisp/treesit.el
index 749781894b..300a703515 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1418,6 +1418,8 @@ treesit--indent-1
          ;; encompass the whitespace.
          (parent (cond ((and node parser)
                         (treesit-node-parent node))
+                       ((equal (treesit-node-type smallest-node) "}")
+                        (treesit-node-parent smallest-node))
                        (t (treesit-node-on bol bol)))))
       (funcall treesit-indent-function node parent bol))))
 




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at 61502 <at> debbugs.gnu.org:


Received: (at 61502) by debbugs.gnu.org; 14 Feb 2023 13:17:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 14 08:17:21 2023
Received: from localhost ([127.0.0.1]:52875 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pRvBR-0000OI-1Y
	for submit <at> debbugs.gnu.org; Tue, 14 Feb 2023 08:17:21 -0500
Received: from eggs.gnu.org ([209.51.188.92]:52766)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pRvBL-0000Nw-UL
 for 61502 <at> debbugs.gnu.org; Tue, 14 Feb 2023 08:17:19 -0500
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 <eliz@HIDDEN>)
 id 1pRvBG-0004JZ-8M; Tue, 14 Feb 2023 08:17:10 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=NIRTQWilSKphj+GiS9hvkNZ9ji4/kcBza+gSy3q8nY4=; b=c8UzrTo0z02x
 2sPzDkEJ/8QUEmvVMLfInM17v4WK5HeObURIcHyX3ATJ0SOOEzvCtr9rmmNwPMiEUrtLJ+YYGOZOS
 1TFFmDJv0o68dW8w0mEl+d18+RiZIneiWTK4KrfuyaHToyRixBh/BrQww7TXjVCM2CKY8SWyBCBF+
 q9mKcq6OZ1LMfhmsyPmH8nQt7YCM7h5aHg0UfXPIUHX89P/SGAqN2LocoGGXSILm8mQp5prTnVPBQ
 +sOt4dg/W2leDCzKai+584g/3Nx49SbiHvUUXs6SSsxIKLAywhonSAmsbeBpM1BHkszY0OKQf4/5m
 GnCwZBYSIjvRW7jsZKO58g==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pRvBF-0002ir-F0; Tue, 14 Feb 2023 08:17:09 -0500
Date: Tue, 14 Feb 2023 15:16:47 +0200
Message-Id: <83a61ge69s.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Pankaj Jangid <pankaj@HIDDEN>, Yuan Fu <casouri@HIDDEN>,
 Theodor Thornhill <theo@HIDDEN>
In-Reply-To: <87v8k4g8xu.fsf@HIDDEN> (message from Pankaj Jangid on
 Tue, 14 Feb 2023 10:06:13 +0530)
Subject: Re: bug#61502: 29.0.60; c-ts-mode auto-indent not working
References: <87v8k4g8xu.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61502
Cc: 61502 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Pankaj Jangid <pankaj@HIDDEN>
> Date: Tue, 14 Feb 2023 10:06:13 +0530
> 
> 
> The auto-indent is not working when using c-ts-mode.
> 
> Steps:
> 
> 1. create a new file test.c
> 
> 2. After typing following snippet, the indentation should work
> automatically on RET. But even the TAB is not indenting the next line
> (after the RET),
> 
> --8<---------------cut here---------------start------------->8---
> int main()
> {
> --8<---------------cut here---------------end--------------->8---

Keep typing whatever code you wan "int main" to include, and it will
auto-indent soon enough.

So I'm not sure your expectations are necessarily true; they could be
just something you are used to in CC mode.  But I'll let Yuan and Theo
chime in and tell whether a single RET here is supposed to
auto-indent.  Does c-ts-mode really always reindents on RET?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 14 Feb 2023 04:36:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 13 23:36:23 2023
Received: from localhost ([127.0.0.1]:52233 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pRn3H-0008QA-8k
	for submit <at> debbugs.gnu.org; Mon, 13 Feb 2023 23:36:23 -0500
Received: from lists.gnu.org ([209.51.188.17]:36430)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pankaj@HIDDEN>) id 1pRn3E-0008Q2-IC
 for submit <at> debbugs.gnu.org; Mon, 13 Feb 2023 23:36:21 -0500
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 <pankaj@HIDDEN>)
 id 1pRn3E-00084A-9J
 for bug-gnu-emacs@HIDDEN; Mon, 13 Feb 2023 23:36:20 -0500
Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <pankaj@HIDDEN>)
 id 1pRn3C-0001mP-4d
 for bug-gnu-emacs@HIDDEN; Mon, 13 Feb 2023 23:36:20 -0500
Received: by mail-pj1-x102a.google.com with SMTP id
 a8-20020a17090a6d8800b002336b48f653so13026980pjk.3
 for <bug-gnu-emacs@HIDDEN>; Mon, 13 Feb 2023 20:36:17 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=codeisgreat-org.20210112.gappssmtp.com; s=20210112;
 h=mime-version:message-id:date:subject:to:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=GtJ170xdqyDfZ/8Amiwbo6eKyJHtI9fOy/+tb3eywoE=;
 b=nf6Dcfi46x47h4uanL4r6SkT9MxVn+n4hFPgkVBjT4/A/cushph/nPlonE7gW8dE67
 /XcXC7KgrcaFLojNQrBY+T3kXktU8rb7bmPORZ7jzzoymGJTPa2BBDiY5f8RroMjORid
 XSWmP8YAdrZ1syfYsdIjXm6cGCTHCXxFDGWFD6rm+eSPHrdf2pt0Fsst7ob33LLAMKhx
 zAURDPKV2D5GD7huJEDZGQ1+E1flQBN4rY5Yjw8oJxbfoFB5X60dPYUdT6CSspZEK7mY
 nsgZyTM3gEpVxxqxM+ozfPCkP3P+22sn6RI+VGDdtDggFd3UeEauZHm2KfMWHGFUBz/M
 yWaw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=mime-version:message-id:date:subject:to:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=GtJ170xdqyDfZ/8Amiwbo6eKyJHtI9fOy/+tb3eywoE=;
 b=q0nsmjo4mdZywRoy+VQijTQ43IggaI09oHuicumrxUi+NWIjr03Eo5pqxOPqsD8ILr
 KOcg37ymqvHzRkCWktv0k726cDTaJUJlHAmgAlmKNNlY7yMLDDzJpvDYpkNl2BkGZWDZ
 7pu9uBKExvcdzctEOpMOrYAirtMjIk0fOgPQse5z8HBJgoJQqVCp0epGpNJBYfgIPxNR
 l/ii1GLgvO68ZWcq8XiOjCNr5byb3IIrVHCq/myyUiQaoAWwFBEaGB5uVlnTWKY4MnHH
 WMZeakBtMR0x8g3apDWWPYgrfVyVU0V0GFfvA9YZxLOAfO11XdzURNBSGDAKeLfHJtha
 GfZg==
X-Gm-Message-State: AO0yUKXBrR8fN4T+tsuqUEt1PFuW2Hhkh+wY/op19/rUH23F+qBtbmb2
 S42RWb/y8NkOedthuIW8DAKUAGzB0cN6ZOhO
X-Google-Smtp-Source: AK7set93kG2Ru6v360if7lD6TtkOgx0q+iyvREHd+U7Rlv3DxX22NtLA71h8FZ9KbCtkUHpQXBzjxg==
X-Received: by 2002:a17:90b:4d0d:b0:234:b23:ead2 with SMTP id
 mw13-20020a17090b4d0d00b002340b23ead2mr1039338pjb.45.1676349375918; 
 Mon, 13 Feb 2023 20:36:15 -0800 (PST)
Received: from anant ([49.36.238.47]) by smtp.gmail.com with ESMTPSA id
 t13-20020a17090a6a0d00b0023417fec520sm1326852pjj.44.2023.02.13.20.36.14
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 13 Feb 2023 20:36:15 -0800 (PST)
From: Pankaj Jangid <pankaj@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.0.60; c-ts-mode auto-indent not working
Date: Tue, 14 Feb 2023 10:06:13 +0530
Message-ID: <87v8k4g8xu.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: none client-ip=2607:f8b0:4864:20::102a;
 envelope-from=pankaj@HIDDEN; helo=mail-pj1-x102a.google.com
X-Spam_score_int: -15
X-Spam_score: -1.6
X-Spam_bar: -
X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NONE=0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.1 (---)


The auto-indent is not working when using c-ts-mode.

Steps:

1. create a new file test.c

2. After typing following snippet, the indentation should work
automatically on RET. But even the TAB is not indenting the next line
(after the RET),

--8<---------------cut here---------------start------------->8---
int main()
{
--8<---------------cut here---------------end--------------->8---



In GNU Emacs 29.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.24, cairo version 1.16.0) of 2023-02-14 built on anant
Repository revision: cc30422825a5acf460d026bfe912b327b70dedcf
Repository branch: HEAD
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure --prefix=/home/pankaj/.local --with-tree-sitter --with-pgtk'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB

Important settings:
  value of $LANG: en_IN.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: C

Minor modes in effect:
  TeX-PDF-mode: t
  eglot--managed-mode: t
  corfu-mode: t
  display-fill-column-indicator-mode: t
  override-global-mode: t
  direnv-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  server-mode: t
  editorconfig-mode: t
  flymake-mode: t
  which-key-mode: t
  global-hl-line-mode: t
  savehist-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  tab-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/pankaj/.emacs.d/elpa/transient-20230213.1337/transient hides /home/pankaj/.local/share/emacs/29.0.60/lisp/transient

Features:
(shadow bbdb-message emacsbug sort smiley gnus-cite mail-extr textsec
uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check
gnus-async gnus-bcklg qp gnus-ml disp-table cursor-sensor utf-7 nndraft
nnmh nnfolder nnml epa-file network-stream bbdb-gnus bbdb-mua bbdb-com
nnnil gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg nntp
gnus-cache .gnus cl-print help-fns radix-tree diary-lib diary-loaddefs
tramp-cache time-stamp prettier tramp tramp-loaddefs trampver
tramp-integration cus-edit cus-start cus-load tramp-compat ls-lisp nvm f
f-shortdoc iter2 yaml-mode flyspell ispell bug-reference conf-mode
sh-script smie executable gnus-dired dired-aux make-mode reftex-dcr
reftex reftex-loaddefs reftex-vars tex-bar toolbar-x font-latex latexenc
preview latex latex-flymake tex-ispell tex-style tex texmathp tex-mode
display-line-numbers oc-basic ol-eww eww url-queue mm-url ol-rmail
ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view
mml-smime smime gnutls dig gnus-sum gnus-group gnus-undo ol-docview
doc-view image-mode exif ol-bibtex bibtex ol-bbdb ol-w3m ol-doi
org-link-doi vc-git vc-dispatcher cmake-ts-mode mule-util jka-compr
vc-svn eglot external-completion array jsonrpc ert ewoc debug backtrace
c-ts-mode checkdoc lisp-mnt corfu display-fill-column-indicator init
my-init kunji hdfc ob-plantuml ob-sql ob-css ob-js ob-java ob-C
ob-python python gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail
mail-source utf7 nnoo parse-time gnus-spec gnus-int gnus-range gnus-win
gnus nnheader range erc-join erc-goodies erc iso8601 erc-backend
erc-networks erc-common erc-compat erc-loaddefs solar cal-dst
use-package-delight rust-ts-mode use-package-bind-key bind-key js
c-ts-common desktop frameset treesit direnv magit-bookmark
magit-submodule magit-obsolete magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log which-func magit-diff
smerge-mode diff diff-mode easy-mmode git-commit log-edit pcvs-util
add-log magit-core magit-autorevert autorevert filenotify magit-margin
magit-transient magit-process with-editor shell server magit-mode
transient edmacro kmacro magit-git magit-base magit-section crm compat
org-mime message sendmail yank-media rfc822 mml mml-sec epa derived epg
rfc6068 epg-config gnus-util mailabbrev mail-utils gmm-utils mailheader
ox-org ox-odt rng-loc rng-uri rng-parse rng-match rng-pttrn nxml-parse
nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar org-agenda
ox-html table ox-ascii ox-publish ox org-element org-persist org-id
org-refile avl-tree debbugs soap-client mm-decode mm-bodies mm-encode
url-http url-auth mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr url-gw nsm rng-xsd rng-dt rng-util xsd-regexp plantuml-mode
solidity-mode solidity-common php-mode mode-local speedbar ezimage
dframe cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
php-face php php-project cc-engine cc-vars cc-defs gnuplot info-look
docker-compose-mode nov recentf tree-widget wid-edit org ob ob-tangle
ob-ref ob-lob ob-table ob-exp org-macro org-src ob-comint org-pcomplete
pcomplete org-list org-footnote org-faces org-entities time-date
ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold
org-fold-core org-keys oc org-loaddefs find-func cal-menu calendar
cal-loaddefs org-version org-compat org-macs format-spec imenu bookmark
pp shr pixel-fill kinsoku url-file puny svg xml esxml-query dom
markdown-mode color groovy-mode dash s graphql-mode let-alist
editorconfig editorconfig-core editorconfig-core-handle
editorconfig-fnmatch haskell-mode haskell-cabal haskell-utils
haskell-font-lock haskell-indentation haskell-string
haskell-sort-imports haskell-lexeme rx haskell-align-imports
haskell-complete-module haskell-ghc-support noutline outline
flymake-proc flymake warnings icons dabbrev haskell-customize go-mode
find-file ffap thingatpt etags fileloop generator compile
text-property-search comint ansi-osc ansi-color gtags-mode files-x
denote xdg dired dired-loaddefs xref project ring which-key
exec-path-from-shell bbdb bbdb-site timezone delight cl-extra help-mode
use-package-ensure use-package-core modus-vivendi-theme modus-themes
pcase hl-line savehist finder-inf solidity-mode-autoloads
spinner-autoloads org-mime-autoloads prettier-autoloads
groovy-mode-autoloads php-mode-autoloads nvm-autoloads f-autoloads
iter2-autoloads haskell-mode-autoloads editorconfig-autoloads
denote-autoloads json-snatcher-autoloads which-key-autoloads
docker-compose-mode-autoloads exec-path-from-shell-autoloads
corfu-autoloads debbugs-autoloads parseedn-autoloads auctex-autoloads
tex-site bbdb-autoloads markdown-mode-autoloads magit-autoloads
magit-section-autoloads git-commit-autoloads with-editor-autoloads
yaml-mode-autoloads parseclj-autoloads gtags-mode-autoloads
go-mode-autoloads plantuml-mode-autoloads gnuplot-autoloads
nov-autoloads esxml-autoloads kv-autoloads 0blayout-autoloads
delight-autoloads 750words-autoloads queue-autoloads s-autoloads
graphql-mode-autoloads transient-autoloads compat-autoloads
direnv-autoloads info dash-autoloads sesman-autoloads lua-mode-autoloads
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
password-cache json subr-x map byte-opt gv bytecomp byte-compile
url-vars cl-loaddefs cl-lib early-init rmc iso-transl tooltip cconv
eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/pgtk-win pgtk-win term/common-win pgtk-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs theme-loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
gtk pgtk lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 1317833 44349)
 (symbols 48 62086 53)
 (strings 32 272989 5267)
 (string-bytes 1 7987872)
 (vectors 16 138971)
 (vector-slots 8 2532888 146933)
 (floats 8 1064 92)
 (intervals 56 2969 0)
 (buffers 984 101))




Acknowledgement sent to Pankaj Jangid <pankaj@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#61502; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 15 Feb 2023 18:30:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.