From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Noah Peart Newsgroups: gmane.emacs.bugs Subject: bug#67357: [PATCH] Fix c-ts-mode block indent when first-siblings are comments Date: Fri, 24 Nov 2023 05:47:34 -0800 Message-ID: References: <834jhchqha.fsf@gnu.org> <08e16d44-174d-87e6-aa17-8cf55202227b@gutov.dev> <83wmu8fsj7.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000758e31060ae63207" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20949"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 67357@debbugs.gnu.org, casouri@gmail.com To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 24 14:49:20 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r6WYZ-00059A-Tq for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Nov 2023 14:49:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6WYF-0007XX-Co; Fri, 24 Nov 2023 08:48:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6WYE-0007X3-BM for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 08:48:58 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r6WYE-0007rF-3H for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 08:48:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r6WYI-000557-5C for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 08:49:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noah Peart Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Nov 2023 13:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67357 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 67357-submit@debbugs.gnu.org id=B67357.170083368219216 (code B ref 67357); Fri, 24 Nov 2023 13:49:02 +0000 Original-Received: (at 67357) by debbugs.gnu.org; 24 Nov 2023 13:48:02 +0000 Original-Received: from localhost ([127.0.0.1]:35968 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6WXJ-0004ze-J1 for submit@debbugs.gnu.org; Fri, 24 Nov 2023 08:48:02 -0500 Original-Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]:54774) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6WXD-0004yN-Vv for 67357@debbugs.gnu.org; Fri, 24 Nov 2023 08:47:59 -0500 Original-Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6d7f3fc69f4so1054729a34.1 for <67357@debbugs.gnu.org>; Fri, 24 Nov 2023 05:47:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700833666; x=1701438466; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iZIV+PtGSR4uetMj2QBNciiDRAy0GDgLoQQTWaTn7cI=; b=SJ3ni4JRB3/De9IForiAa8bt4ZcHfsYxlyT0gK/AXG5yismcRpXOx76IwzMXCAFaPT azVDgDQ3FaDmwGSUFuXfES7nOtn+S89cFagLWE29/K4ySg/Jnp6EJ6UlScywZziONc4P nIrT0shpe5+HeOGRO95HtIWAiwe4XtOA+DkgXER1n7Z0hgX4wFsy5jaqLqHB/sSNWHtf yJfoS+2N+u7ggAQrxCuUaerC7d2649xK69ULrvZReZLoXOIiNYRDC5HNRkHSV2NT2olm iQqQ/5KF2NEMtHXGtW999I4rSxJphRxvuv22DEhClNnktWKfKLfO2BeTcpQV/sOCf5c6 mgPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700833666; x=1701438466; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iZIV+PtGSR4uetMj2QBNciiDRAy0GDgLoQQTWaTn7cI=; b=OszqJtWmqzcamIiqZ/yuFU8YpvVMLF9Ze65PWFHeL2RfD1EHvT4lfv9+s7SNTuTFtv uQ3snG67Lh954V8wqhEl15EI7l14iaAq/xTA7/epAfBAEKsd6ltttuvZ7im1Kxb9inFK Yq5wIBvUtCVZRGPeRpu1KS1B3/almpHmlDfPyUDJwZJzRPl5I+V76rXPGggEPvhBAhlL sK12fJ7DChOrgad3Io2X4dSk5uW1iTe/QIfsbDTTDliZRlRlT8HNeXiNmZj1klCVH3zZ QLCuvgPNbh6VTp7DBz014KGKVZBuO3KjlddU5AuVubm3A0HM/MF0f74ziW+QlHEZROEH OUuQ== X-Gm-Message-State: AOJu0Yz8ynxAq0McY0AmvtmtYKr9G4gOOBq+7x28pZCsz4lh/DELMCKc XdUCVxXTR2+obOGFgtrg1EPnxeCVZbJ55E4F6B8= X-Google-Smtp-Source: AGHT+IF7prhNjPuQ1g6Gx3StqoGemxUidlO3qc5YLfgfnWFjeOJMRfVfe98uTIqEExydjXdGDdLq892+thtf4nR/Mz0= X-Received: by 2002:a05:6870:b4a9:b0:1f5:c858:2efe with SMTP id y41-20020a056870b4a900b001f5c8582efemr3121453oap.0.1700833665583; Fri, 24 Nov 2023 05:47:45 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:274859 Archived-At: --000000000000758e31060ae63207 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sorry for the confusion: to setup the `c-ts-mode` buffers to reproduce bugs= , run the following to configure `c-ts-mode` with `linux` style: (defun example-setup () (interactive) (c-ts-mode) (setq-local indent-tabs-mode nil) (setq-local c-ts-mode-indent-offset 2) (c-ts-mode-set-style 'linux)) The patch should also fix the missing indent for the `else_clause` mentioned in https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-11/msg01266.html. On Thu, Nov 23, 2023 at 6:41=E2=80=AFAM Dmitry Gutov wro= te: > On 23/11/2023 16:33, Eli Zaretskii wrote: > >> Date: Thu, 23 Nov 2023 15:17:40 +0200 > >> Cc: 67357@debbugs.gnu.org > >> From: Dmitry Gutov > >> > >> On 23/11/2023 09:35, Eli Zaretskii wrote: > >>> I'm not sure I can reproduce these, it seems to me that the > >>> indentation is correct in these case when I try the examples. So > >>> please show a detailed recipe, starting from "emacs -Q", for each of > >>> the two problems, so that we could be sure that we are seeing the sam= e > >>> problems. > >> > >> I can easily reproduce the first one (comment-related): the two > >> indicated lines just don't reindent at all. That's with the default > >> 'gnu' indentation style, but also with 'linux' and perhaps others (I > >> haven't tried). > > > > I don't understand what you mean by "reindent". That wasn't what the > > original report was about, AFAIU. > > Reindent is when you press tab, and the indentation on a given line > changes. In that example, no matter which indentation you set on those > line, pressing TAB doesn't change it. > > > I still think a complete recipe is needed. > > > >> To reproduce the second one, you first need to enable the 'linux' styl= e: > > > > I tried to reproduce _only_ with the 'linux' style, as the bug report > > said. > > > >> (setq c-ts-mode-indent-style 'linux) > >> M-x c-ts-mode > > > > The style is a per-buffer setting, so AFAIU one needs to set the style > > after turning on the mode in a buffer, whether manually or > > automatically. > > Did you use 'M-x c-ts-mode-set-style', then? That also repros for me. > > The style can be set locally - as the above command does - but initially > the global value is used. And it's applied during the major mode's > execution, so a simple 'setq' doesn't work. > > > A full recipe is supposed to remove all those confusing details and > > potential mistakes. > > I don't mind. > --000000000000758e31060ae63207 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Sorry for the confusion: to setup=C2=A0the `c-ts-mode` buf= fers to reproduce bugs,
run the following to configure `c-ts-mode` with= `linux` style:

=C2=A0 =C2=A0 (defun example-setup = ()
=C2=A0 =C2=A0 =C2=A0 (interactive)
=C2=A0 =C2=A0 =C2=A0 (c-ts-mode= )
=C2=A0 =C2=A0 =C2=A0 (setq-local indent-tabs-mode nil)
=C2=A0 =C2= =A0 =C2=A0 (setq-local c-ts-mode-indent-offset 2)
=C2=A0 =C2=A0 =C2=A0 (= c-ts-mode-set-style 'linux))

T= he patch should also fix the missing indent for the `else_clause` mentioned= =C2=A0

On Thu, Nov 23, 2023 at 6:41=E2=80= =AFAM Dmitry Gutov <dmitry@gutov.dev= > wrote:
= On 23/11/2023 16:33, Eli Zaretskii wrote:
>> Date: Thu, 23 Nov 2023 15:17:40 +0200
>> Cc: 673= 57@debbugs.gnu.org
>> From: Dmitry Gutov <dmitry@gutov.dev>
>>
>> On 23/11/2023 09:35, Eli Zaretskii wrote:
>>> I'm not sure I can reproduce these, it seems to me that th= e
>>> indentation is correct in these case when I try the examples.= =C2=A0 So
>>> please show a detailed recipe, starting from "emacs -Q&qu= ot;, for each of
>>> the two problems, so that we could be sure that we are seeing = the same
>>> problems.
>>
>> I can easily reproduce the first one (comment-related): the two >> indicated lines just don't reindent at all. That's with th= e default
>> 'gnu' indentation style, but also with 'linux' and= perhaps others (I
>> haven't tried).
>
> I don't understand what you mean by "reindent".=C2=A0 Th= at wasn't what the
> original report was about, AFAIU.

Reindent is when you press tab, and the indentation on a given line
changes. In that example, no matter which indentation you set on those
line, pressing TAB doesn't change it.

> I still think a complete recipe is needed.
>
>> To reproduce the second one, you first need to enable the 'lin= ux' style:
>
> I tried to reproduce _only_ with the 'linux' style, as the bug= report
> said.
>
>>=C2=A0 =C2=A0 =C2=A0(setq c-ts-mode-indent-style 'linux)
>>=C2=A0 =C2=A0 =C2=A0M-x c-ts-mode
>
> The style is a per-buffer setting, so AFAIU one needs to set the style=
> after turning on the mode in a buffer, whether manually or
> automatically.

Did you use 'M-x c-ts-mode-set-style', then? That also repros for m= e.

The style can be set locally - as the above command does - but initially the global value is used. And it's applied during the major mode's =
execution, so a simple 'setq' doesn't work.

> A full recipe is supposed to remove all those confusing details and > potential mistakes.

I don't mind.
--000000000000758e31060ae63207--