all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
@ 2023-11-10  1:29 nvp
  2023-11-15 13:40 ` Eli Zaretskii
  0 siblings, 1 reply; 22+ messages in thread
From: nvp @ 2023-11-10  1:29 UTC (permalink / raw)
  To: 67031


[-- Attachment #1.1: Type: text/plain, Size: 1046 bytes --]

Tags: patch


* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--indent-rules): fix indentation after statements
without brackets

Bug: There are no indentation rules for statement bodies following
if/for/for_in/do/while statements without brackets.

Recipe to reproduce:
In a `typescript-ts-mode` buffer with the following code,

    if (true)
    console.log('No indent here')

Try to indent the second line.

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2023-11-05 built on noah-X580VD
Repository revision: b819b8d6e90337b4cb36b35c2c6d0112c90a8e24
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.3 LTS

Configured using:
 'configure --prefix=/usr/local --with-modules --with-tree-sitter
--with-threads --with-x-toolkit=gtk3 --with-xwidgets --with-gnutls
--with-json --with-mailutils --with-jpeg --with-png --with-rsvg
--with-tiff --with-xml2 --with-xpm --with-imagemagick CC=gcc-12
CXX=gcc-12'

[-- Attachment #1.2: Type: text/html, Size: 1192 bytes --]

[-- Attachment #2: typescript-ts-mode-indentation.patch --]
[-- Type: text/x-patch, Size: 1172 bytes --]

From 2014793a7ca370f25978a3d0bd6ac6fdb2fb2ca9 Mon Sep 17 00:00:00 2001
From: nverno <noah.v.peart@gmail.com>
Date: Thu, 9 Nov 2023 17:19:34 -0800
Subject: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements

---
 lisp/progmodes/typescript-ts-mode.el | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index b976145dbf3..e671ad5d2d7 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -124,6 +124,10 @@ typescript-ts-mode--indent-rules
      ((parent-is "arrow_function") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "parenthesized_expression") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "binary_expression") parent-bol typescript-ts-mode-indent-offset)
+     ((match "while" "do_statement") parent-bol 0)
+     ((match "else" "if_statement") parent-bol 0)
+     ((parent-is ,(rx (seq (or "if" "for" "for_in" "while" "do") "_statement")))
+      parent-bol typescript-ts-mode-indent-offset)
 
      ,@(when (eq language 'tsx)
 	 (append (tsx-ts-mode--indent-compatibility-b893426)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-10  1:29 bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements nvp
@ 2023-11-15 13:40 ` Eli Zaretskii
  2023-11-16  1:18   ` Dmitry Gutov
  0 siblings, 1 reply; 22+ messages in thread
From: Eli Zaretskii @ 2023-11-15 13:40 UTC (permalink / raw)
  To: nvp, Dmitry Gutov, Yuan Fu; +Cc: 67031

> From: nvp <noah.v.peart@gmail.com>
> Date: Thu, 9 Nov 2023 17:29:21 -0800
> 
> Tags: patch
> 
> * lisp/progmodes/typescript-ts-mode.el
> (typescript-ts-mode--indent-rules): fix indentation after statements
> without brackets
> 
> Bug: There are no indentation rules for statement bodies following
> if/for/for_in/do/while statements without brackets.
> 
> Recipe to reproduce:
> In a `typescript-ts-mode` buffer with the following code, 
> 
>     if (true)
>     console.log('No indent here')
> 
> Try to indent the second line.

Dmitry, Yuan: any comments?





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-15 13:40 ` Eli Zaretskii
@ 2023-11-16  1:18   ` Dmitry Gutov
  2023-11-18 10:05     ` Eli Zaretskii
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Gutov @ 2023-11-16  1:18 UTC (permalink / raw)
  To: Eli Zaretskii, nvp, Yuan Fu; +Cc: 67031

On 15/11/2023 15:40, Eli Zaretskii wrote:
>> From: nvp<noah.v.peart@gmail.com>
>> Date: Thu, 9 Nov 2023 17:29:21 -0800
>>
>> Tags: patch
>>
>> * lisp/progmodes/typescript-ts-mode.el
>> (typescript-ts-mode--indent-rules): fix indentation after statements
>> without brackets
>>
>> Bug: There are no indentation rules for statement bodies following
>> if/for/for_in/do/while statements without brackets.
>>
>> Recipe to reproduce:
>> In a `typescript-ts-mode` buffer with the following code,
>>
>>      if (true)
>>      console.log('No indent here')
>>
>> Try to indent the second line.
> Dmitry, Yuan: any comments?

I think it would be cool if the patch added a corresponding new case or 
two in test/lisp/progmodes/typescript-ts-mode-resources/indent.erts





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-16  1:18   ` Dmitry Gutov
@ 2023-11-18 10:05     ` Eli Zaretskii
  2023-11-19  0:12       ` Noah Peart
  2023-11-19  4:26       ` Yuan Fu
  0 siblings, 2 replies; 22+ messages in thread
From: Eli Zaretskii @ 2023-11-18 10:05 UTC (permalink / raw)
  To: casouri, noah.v.peart, Dmitry Gutov; +Cc: 67031

> Date: Thu, 16 Nov 2023 03:18:44 +0200
> Cc: 67031@debbugs.gnu.org
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> On 15/11/2023 15:40, Eli Zaretskii wrote:
> >> From: nvp<noah.v.peart@gmail.com>
> >> Date: Thu, 9 Nov 2023 17:29:21 -0800
> >>
> >> Tags: patch
> >>
> >> * lisp/progmodes/typescript-ts-mode.el
> >> (typescript-ts-mode--indent-rules): fix indentation after statements
> >> without brackets
> >>
> >> Bug: There are no indentation rules for statement bodies following
> >> if/for/for_in/do/while statements without brackets.
> >>
> >> Recipe to reproduce:
> >> In a `typescript-ts-mode` buffer with the following code,
> >>
> >>      if (true)
> >>      console.log('No indent here')
> >>
> >> Try to indent the second line.
> > Dmitry, Yuan: any comments?
> 
> I think it would be cool if the patch added a corresponding new case or 
> two in test/lisp/progmodes/typescript-ts-mode-resources/indent.erts

Noah, would you please add such tests?

Yuan, any comments or suggestions?





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-18 10:05     ` Eli Zaretskii
@ 2023-11-19  0:12       ` Noah Peart
  2023-11-19  1:24         ` Dmitry Gutov
  2023-11-19  4:26       ` Yuan Fu
  1 sibling, 1 reply; 22+ messages in thread
From: Noah Peart @ 2023-11-19  0:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Dmitry Gutov, casouri, 67031

[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]

Yea, I can do that.

Is there a recipe for running the tests with a tree-sitter library path?

On Sat, Nov 18, 2023 at 2:05 AM Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Thu, 16 Nov 2023 03:18:44 +0200
> > Cc: 67031@debbugs.gnu.org
> > From: Dmitry Gutov <dmitry@gutov.dev>
> >
> > On 15/11/2023 15:40, Eli Zaretskii wrote:
> > >> From: nvp<noah.v.peart@gmail.com>
> > >> Date: Thu, 9 Nov 2023 17:29:21 -0800
> > >>
> > >> Tags: patch
> > >>
> > >> * lisp/progmodes/typescript-ts-mode.el
> > >> (typescript-ts-mode--indent-rules): fix indentation after statements
> > >> without brackets
> > >>
> > >> Bug: There are no indentation rules for statement bodies following
> > >> if/for/for_in/do/while statements without brackets.
> > >>
> > >> Recipe to reproduce:
> > >> In a `typescript-ts-mode` buffer with the following code,
> > >>
> > >>      if (true)
> > >>      console.log('No indent here')
> > >>
> > >> Try to indent the second line.
> > > Dmitry, Yuan: any comments?
> >
> > I think it would be cool if the patch added a corresponding new case or
> > two in test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
>
> Noah, would you please add such tests?
>
> Yuan, any comments or suggestions?
>

[-- Attachment #2: Type: text/html, Size: 2016 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-19  0:12       ` Noah Peart
@ 2023-11-19  1:24         ` Dmitry Gutov
  2023-11-19  6:08           ` Eli Zaretskii
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Gutov @ 2023-11-19  1:24 UTC (permalink / raw)
  To: Noah Peart, Eli Zaretskii; +Cc: casouri, 67031

On 19/11/2023 02:12, Noah Peart wrote:
> Yea, I can do that.
> 
> Is there a recipe for running the tests with a tree-sitter library path?

You mean with the default tree-sitter librayr path overridden? I'm not sure.

But note that you can run an ert test in your interactive session, or 
alter treesit-extra-load-path temporarily at the beginning of the ert 
test file, at least while you debug it locally.





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-18 10:05     ` Eli Zaretskii
  2023-11-19  0:12       ` Noah Peart
@ 2023-11-19  4:26       ` Yuan Fu
  1 sibling, 0 replies; 22+ messages in thread
From: Yuan Fu @ 2023-11-19  4:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: noah.v.peart, 67031, Dmitry Gutov



> On Nov 18, 2023, at 2:05 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> Date: Thu, 16 Nov 2023 03:18:44 +0200
>> Cc: 67031@debbugs.gnu.org
>> From: Dmitry Gutov <dmitry@gutov.dev>
>> 
>> On 15/11/2023 15:40, Eli Zaretskii wrote:
>>>> From: nvp<noah.v.peart@gmail.com>
>>>> Date: Thu, 9 Nov 2023 17:29:21 -0800
>>>> 
>>>> Tags: patch
>>>> 
>>>> * lisp/progmodes/typescript-ts-mode.el
>>>> (typescript-ts-mode--indent-rules): fix indentation after statements
>>>> without brackets
>>>> 
>>>> Bug: There are no indentation rules for statement bodies following
>>>> if/for/for_in/do/while statements without brackets.
>>>> 
>>>> Recipe to reproduce:
>>>> In a `typescript-ts-mode` buffer with the following code,
>>>> 
>>>>     if (true)
>>>>     console.log('No indent here')
>>>> 
>>>> Try to indent the second line.
>>> Dmitry, Yuan: any comments?
>> 
>> I think it would be cool if the patch added a corresponding new case or 
>> two in test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
> 
> Noah, would you please add such tests?
> 
> Yuan, any comments or suggestions?

LGTM, I’ll also add else_clause too, like

((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") "_statement")
                     "else_clause")))
 parent-bol typescript-ts-mode-indent-offset)

Yuan






^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-19  1:24         ` Dmitry Gutov
@ 2023-11-19  6:08           ` Eli Zaretskii
  2023-11-19  7:19             ` Noah Peart
  2023-11-19 13:38             ` Dmitry Gutov
  0 siblings, 2 replies; 22+ messages in thread
From: Eli Zaretskii @ 2023-11-19  6:08 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: noah.v.peart, casouri, 67031

> Date: Sun, 19 Nov 2023 03:24:49 +0200
> Cc: casouri@gmail.com, 67031@debbugs.gnu.org
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> On 19/11/2023 02:12, Noah Peart wrote:
> > Yea, I can do that.
> > 
> > Is there a recipe for running the tests with a tree-sitter library path?
> 
> You mean with the default tree-sitter librayr path overridden? I'm not sure.

Why would an ERT test need that?  We are supposed to test Emacs with
the otherwise installed system features.  As tree-sitter grammars are
not part of Emacs, there should be no need to tell Emacs to use a
grammar library other than the one installed on the system.  Right?





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-19  6:08           ` Eli Zaretskii
@ 2023-11-19  7:19             ` Noah Peart
  2023-11-19 13:38             ` Dmitry Gutov
  1 sibling, 0 replies; 22+ messages in thread
From: Noah Peart @ 2023-11-19  7:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Dmitry Gutov, casouri, 67031

[-- Attachment #1: Type: text/plain, Size: 933 bytes --]

I don't think the test runs when it doesn't find a typescript parser.  Ill
double check
tomorrow, but temporarily adding a treesit-extra load path should be ok.

Thanks

On Sat, Nov 18, 2023 at 10:08 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Sun, 19 Nov 2023 03:24:49 +0200
> > Cc: casouri@gmail.com, 67031@debbugs.gnu.org
> > From: Dmitry Gutov <dmitry@gutov.dev>
> >
> > On 19/11/2023 02:12, Noah Peart wrote:
> > > Yea, I can do that.
> > >
> > > Is there a recipe for running the tests with a tree-sitter library
> path?
> >
> > You mean with the default tree-sitter librayr path overridden? I'm not
> sure.
>
> Why would an ERT test need that?  We are supposed to test Emacs with
> the otherwise installed system features.  As tree-sitter grammars are
> not part of Emacs, there should be no need to tell Emacs to use a
> grammar library other than the one installed on the system.  Right?
>

[-- Attachment #2: Type: text/html, Size: 1486 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-19  6:08           ` Eli Zaretskii
  2023-11-19  7:19             ` Noah Peart
@ 2023-11-19 13:38             ` Dmitry Gutov
  2023-11-20 12:55               ` Noah Peart
  1 sibling, 1 reply; 22+ messages in thread
From: Dmitry Gutov @ 2023-11-19 13:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: noah.v.peart, casouri, 67031

On 19/11/2023 08:08, Eli Zaretskii wrote:
>> Date: Sun, 19 Nov 2023 03:24:49 +0200
>> Cc:casouri@gmail.com,67031@debbugs.gnu.org
>> From: Dmitry Gutov<dmitry@gutov.dev>
>>
>> On 19/11/2023 02:12, Noah Peart wrote:
>>> Yea, I can do that.
>>>
>>> Is there a recipe for running the tests with a tree-sitter library path?
>> You mean with the default tree-sitter librayr path overridden? I'm not sure.
> Why would an ERT test need that?  We are supposed to test Emacs with
> the otherwise installed system features.  As tree-sitter grammars are
> not part of Emacs, there should be no need to tell Emacs to use a
> grammar library other than the one installed on the system.  Right?

We have a way to override that with the variable 
treesit-extra-load-path, so it follows that some users will take 
advantage of it to add extra directories.

I'm using ~/.emacs.d/tree-sitter/ myself.





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-19 13:38             ` Dmitry Gutov
@ 2023-11-20 12:55               ` Noah Peart
  2023-11-20 18:07                 ` Noah Peart
  0 siblings, 1 reply; 22+ messages in thread
From: Noah Peart @ 2023-11-20 12:55 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Eli Zaretskii, 67031, casouri

[-- Attachment #1: Type: text/plain, Size: 1208 bytes --]

Yea, I'm using the same.  But, would it be useful to have a way to set that
when
running tests without needing to temporarily add set
`treesit-extra-load-path` in
the test file?

On Sun, Nov 19, 2023 at 5:38 AM Dmitry Gutov <dmitry@gutov.dev> wrote:

> On 19/11/2023 08:08, Eli Zaretskii wrote:
> >> Date: Sun, 19 Nov 2023 03:24:49 +0200
> >> Cc:casouri@gmail.com,67031@debbugs.gnu.org
> >> From: Dmitry Gutov<dmitry@gutov.dev>
> >>
> >> On 19/11/2023 02:12, Noah Peart wrote:
> >>> Yea, I can do that.
> >>>
> >>> Is there a recipe for running the tests with a tree-sitter library
> path?
> >> You mean with the default tree-sitter librayr path overridden? I'm not
> sure.
> > Why would an ERT test need that?  We are supposed to test Emacs with
> > the otherwise installed system features.  As tree-sitter grammars are
> > not part of Emacs, there should be no need to tell Emacs to use a
> > grammar library other than the one installed on the system.  Right?
>
> We have a way to override that with the variable
> treesit-extra-load-path, so it follows that some users will take
> advantage of it to add extra directories.
>
> I'm using ~/.emacs.d/tree-sitter/ myself.
>

[-- Attachment #2: Type: text/html, Size: 1806 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-20 12:55               ` Noah Peart
@ 2023-11-20 18:07                 ` Noah Peart
  2023-11-20 18:13                   ` Noah Peart
  0 siblings, 1 reply; 22+ messages in thread
From: Noah Peart @ 2023-11-20 18:07 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Eli Zaretskii, 67031, casouri


[-- Attachment #1.1: Type: text/plain, Size: 1439 bytes --]

Here is an updated patch with the added "else_clause" and indentation test
for
statements without braces.

On Mon, Nov 20, 2023 at 4:55 AM Noah Peart <noah.v.peart@gmail.com> wrote:

> Yea, I'm using the same.  But, would it be useful to have a way to set
> that when
> running tests without needing to temporarily add set
> `treesit-extra-load-path` in
> the test file?
>
> On Sun, Nov 19, 2023 at 5:38 AM Dmitry Gutov <dmitry@gutov.dev> wrote:
>
>> On 19/11/2023 08:08, Eli Zaretskii wrote:
>> >> Date: Sun, 19 Nov 2023 03:24:49 +0200
>> >> Cc:casouri@gmail.com,67031@debbugs.gnu.org
>> >> From: Dmitry Gutov<dmitry@gutov.dev>
>> >>
>> >> On 19/11/2023 02:12, Noah Peart wrote:
>> >>> Yea, I can do that.
>> >>>
>> >>> Is there a recipe for running the tests with a tree-sitter library
>> path?
>> >> You mean with the default tree-sitter librayr path overridden? I'm not
>> sure.
>> > Why would an ERT test need that?  We are supposed to test Emacs with
>> > the otherwise installed system features.  As tree-sitter grammars are
>> > not part of Emacs, there should be no need to tell Emacs to use a
>> > grammar library other than the one installed on the system.  Right?
>>
>> We have a way to override that with the variable
>> treesit-extra-load-path, so it follows that some users will take
>> advantage of it to add extra directories.
>>
>> I'm using ~/.emacs.d/tree-sitter/ myself.
>>
>

[-- Attachment #1.2: Type: text/html, Size: 2311 bytes --]

[-- Attachment #2: typescript-ts-mode-indentation.patch --]
[-- Type: text/x-patch, Size: 2082 bytes --]

From e38f823238f456a0825b8a4e3f86da6efaac0579 Mon Sep 17 00:00:00 2001
From: nverno <noah.v.peart@gmail.com>
Date: Mon, 20 Nov 2023 10:04:51 -0800
Subject: [PATCH] Fix typescript-ts-mode indentation in statements without
 braces

---
 lisp/progmodes/typescript-ts-mode.el          |  3 +++
 .../typescript-ts-mode-resources/indent.erts  | 22 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index b976145dbf3..826cd5f39b0 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -124,6 +124,9 @@ typescript-ts-mode--indent-rules
      ((parent-is "arrow_function") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "parenthesized_expression") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "binary_expression") parent-bol typescript-ts-mode-indent-offset)
+     ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") "_statement")
+                          "else_clause")))
+      parent-bol typescript-ts-mode-indent-offset)
 
      ,@(when (eq language 'tsx)
 	 (append (tsx-ts-mode--indent-compatibility-b893426)
diff --git a/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts b/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
index 146ee76574e..20f423259b4 100644
--- a/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
@@ -23,6 +23,28 @@ const foo = () => {
 }
 =-=-=
 
+Name: Statement indentation without braces
+
+=-=
+const foo = () => {
+  if (true)
+    console.log("if_statement");
+  else if (false)
+    console.log("if_statement");
+  else
+    console.log("else_clause");
+  for (let i = 0; i < 1; i++)
+    console.log("for_statement");
+  for (let i of [true])
+    console.log("for_in_statement");
+  while (false)
+    console.log("while_statement");
+  do
+    console.log("do_statement");
+  while (false)
+};
+=-=-=
+
 Code:
   (lambda ()
     (setq indent-tabs-mode nil)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-20 18:07                 ` Noah Peart
@ 2023-11-20 18:13                   ` Noah Peart
  2023-11-20 22:28                     ` Dmitry Gutov
  2023-11-25  3:46                     ` Yuan Fu
  0 siblings, 2 replies; 22+ messages in thread
From: Noah Peart @ 2023-11-20 18:13 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Eli Zaretskii, 67031, casouri


[-- Attachment #1.1: Type: text/plain, Size: 1670 bytes --]

Sorry, ignore the previous patch.  A couple additional rules were needed to
handle
"while" and "else".

On Mon, Nov 20, 2023 at 10:07 AM Noah Peart <noah.v.peart@gmail.com> wrote:

> Here is an updated patch with the added "else_clause" and indentation test
> for
> statements without braces.
>
> On Mon, Nov 20, 2023 at 4:55 AM Noah Peart <noah.v.peart@gmail.com> wrote:
>
>> Yea, I'm using the same.  But, would it be useful to have a way to set
>> that when
>> running tests without needing to temporarily add set
>> `treesit-extra-load-path` in
>> the test file?
>>
>> On Sun, Nov 19, 2023 at 5:38 AM Dmitry Gutov <dmitry@gutov.dev> wrote:
>>
>>> On 19/11/2023 08:08, Eli Zaretskii wrote:
>>> >> Date: Sun, 19 Nov 2023 03:24:49 +0200
>>> >> Cc:casouri@gmail.com,67031@debbugs.gnu.org
>>> >> From: Dmitry Gutov<dmitry@gutov.dev>
>>> >>
>>> >> On 19/11/2023 02:12, Noah Peart wrote:
>>> >>> Yea, I can do that.
>>> >>>
>>> >>> Is there a recipe for running the tests with a tree-sitter library
>>> path?
>>> >> You mean with the default tree-sitter librayr path overridden? I'm
>>> not sure.
>>> > Why would an ERT test need that?  We are supposed to test Emacs with
>>> > the otherwise installed system features.  As tree-sitter grammars are
>>> > not part of Emacs, there should be no need to tell Emacs to use a
>>> > grammar library other than the one installed on the system.  Right?
>>>
>>> We have a way to override that with the variable
>>> treesit-extra-load-path, so it follows that some users will take
>>> advantage of it to add extra directories.
>>>
>>> I'm using ~/.emacs.d/tree-sitter/ myself.
>>>
>>

[-- Attachment #1.2: Type: text/html, Size: 2825 bytes --]

[-- Attachment #2: typescript-ts-mode-indentation.patch --]
[-- Type: text/x-patch, Size: 2188 bytes --]

From 2628e92f6c55fb69d9f504caee1e1b105e30e01a Mon Sep 17 00:00:00 2001
From: nverno <noah.v.peart@gmail.com>
Date: Mon, 20 Nov 2023 10:04:51 -0800
Subject: [PATCH] Fix typescript-ts-mode indentation in statements without
 braces

---
 lisp/progmodes/typescript-ts-mode.el          |  5 +++++
 .../typescript-ts-mode-resources/indent.erts  | 22 +++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index b976145dbf3..b6d5495adbb 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -124,6 +124,11 @@ typescript-ts-mode--indent-rules
      ((parent-is "arrow_function") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "parenthesized_expression") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "binary_expression") parent-bol typescript-ts-mode-indent-offset)
+     ((match "while" "do_statement") parent-bol 0)
+     ((match "else" "if_statement") parent-bol 0)
+     ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") "_statement")
+                          "else_clause")))
+      parent-bol typescript-ts-mode-indent-offset)
 
      ,@(when (eq language 'tsx)
 	 (append (tsx-ts-mode--indent-compatibility-b893426)
diff --git a/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts b/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
index 146ee76574e..20f423259b4 100644
--- a/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts
@@ -23,6 +23,28 @@ const foo = () => {
 }
 =-=-=
 
+Name: Statement indentation without braces
+
+=-=
+const foo = () => {
+  if (true)
+    console.log("if_statement");
+  else if (false)
+    console.log("if_statement");
+  else
+    console.log("else_clause");
+  for (let i = 0; i < 1; i++)
+    console.log("for_statement");
+  for (let i of [true])
+    console.log("for_in_statement");
+  while (false)
+    console.log("while_statement");
+  do
+    console.log("do_statement");
+  while (false)
+};
+=-=-=
+
 Code:
   (lambda ()
     (setq indent-tabs-mode nil)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-20 18:13                   ` Noah Peart
@ 2023-11-20 22:28                     ` Dmitry Gutov
  2023-11-21  3:27                       ` Eli Zaretskii
  2023-11-25  3:46                     ` Yuan Fu
  1 sibling, 1 reply; 22+ messages in thread
From: Dmitry Gutov @ 2023-11-20 22:28 UTC (permalink / raw)
  To: Noah Peart; +Cc: Eli Zaretskii, 67031, casouri

On 20/11/2023 20:13, Noah Peart wrote:
> Sorry, ignore the previous patch.  A couple additional rules were needed 
> to handle
> "while" and "else".

Looking good.

Eli, should this go to emacs-29?





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-20 22:28                     ` Dmitry Gutov
@ 2023-11-21  3:27                       ` Eli Zaretskii
  2023-11-21  4:41                         ` Noah Peart
  0 siblings, 1 reply; 22+ messages in thread
From: Eli Zaretskii @ 2023-11-21  3:27 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: noah.v.peart, casouri, 67031

> Date: Tue, 21 Nov 2023 00:28:23 +0200
> Cc: Eli Zaretskii <eliz@gnu.org>, casouri@gmail.com, 67031@debbugs.gnu.org
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> On 20/11/2023 20:13, Noah Peart wrote:
> > Sorry, ignore the previous patch.  A couple additional rules were needed 
> > to handle
> > "while" and "else".
> 
> Looking good.
> 
> Eli, should this go to emacs-29?

Yes.  But we should wait for Noah's legal paperwork to be completed,
before we install.





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-21  3:27                       ` Eli Zaretskii
@ 2023-11-21  4:41                         ` Noah Peart
  2023-11-21 11:44                           ` Eli Zaretskii
  0 siblings, 1 reply; 22+ messages in thread
From: Noah Peart @ 2023-11-21  4:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Dmitry Gutov, casouri, 67031

[-- Attachment #1: Type: text/plain, Size: 681 bytes --]

I believe my copyright assignment is on file - Eli, I think you checked for
me
last month.

On Mon, Nov 20, 2023 at 7:27 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Tue, 21 Nov 2023 00:28:23 +0200
> > Cc: Eli Zaretskii <eliz@gnu.org>, casouri@gmail.com,
> 67031@debbugs.gnu.org
> > From: Dmitry Gutov <dmitry@gutov.dev>
> >
> > On 20/11/2023 20:13, Noah Peart wrote:
> > > Sorry, ignore the previous patch.  A couple additional rules were
> needed
> > > to handle
> > > "while" and "else".
> >
> > Looking good.
> >
> > Eli, should this go to emacs-29?
>
> Yes.  But we should wait for Noah's legal paperwork to be completed,
> before we install.
>

[-- Attachment #2: Type: text/html, Size: 1286 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-21  4:41                         ` Noah Peart
@ 2023-11-21 11:44                           ` Eli Zaretskii
  2023-11-21 14:09                             ` Dmitry Gutov
  0 siblings, 1 reply; 22+ messages in thread
From: Eli Zaretskii @ 2023-11-21 11:44 UTC (permalink / raw)
  To: Noah Peart; +Cc: dmitry, casouri, 67031

> From: Noah Peart <noah.v.peart@gmail.com>
> Date: Mon, 20 Nov 2023 20:41:49 -0800
> Cc: Dmitry Gutov <dmitry@gutov.dev>, casouri@gmail.com, 67031@debbugs.gnu.org
> 
> I believe my copyright assignment is on file - Eli, I think you checked for me 
> last month.

Yes, sorry, my bad.  I was coffee-challenged and therefore confused.

So we can install this right away.





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-21 11:44                           ` Eli Zaretskii
@ 2023-11-21 14:09                             ` Dmitry Gutov
  2023-11-21 14:23                               ` Eli Zaretskii
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Gutov @ 2023-11-21 14:09 UTC (permalink / raw)
  To: Eli Zaretskii, Noah Peart; +Cc: casouri, 67031-done

Version: 29.2

On 21/11/2023 13:44, Eli Zaretskii wrote:
>> From: Noah Peart<noah.v.peart@gmail.com>
>> Date: Mon, 20 Nov 2023 20:41:49 -0800
>> Cc: Dmitry Gutov<dmitry@gutov.dev>,casouri@gmail.com,67031@debbugs.gnu.org
>>
>> I believe my copyright assignment is on file - Eli, I think you checked for me
>> last month.
> Yes, sorry, my bad.  I was coffee-challenged and therefore confused.
> 
> So we can install this right away.

Thanks, installed.

I've also backported the test setup from master, so it'll be easier to 
add changes like this to Emacs 29.2 in the future.





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-21 14:09                             ` Dmitry Gutov
@ 2023-11-21 14:23                               ` Eli Zaretskii
  2023-11-21 14:27                                 ` Dmitry Gutov
  0 siblings, 1 reply; 22+ messages in thread
From: Eli Zaretskii @ 2023-11-21 14:23 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: noah.v.peart, casouri, 67031-done

> Date: Tue, 21 Nov 2023 16:09:34 +0200
> Cc: casouri@gmail.com, 67031-done@debbugs.gnu.org
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> Version: 29.2
> 
> On 21/11/2023 13:44, Eli Zaretskii wrote:
> >> From: Noah Peart<noah.v.peart@gmail.com>
> >> Date: Mon, 20 Nov 2023 20:41:49 -0800
> >> Cc: Dmitry Gutov<dmitry@gutov.dev>,casouri@gmail.com,67031@debbugs.gnu.org
> >>
> >> I believe my copyright assignment is on file - Eli, I think you checked for me
> >> last month.
> > Yes, sorry, my bad.  I was coffee-challenged and therefore confused.
> > 
> > So we can install this right away.
> 
> Thanks, installed.
> 
> I've also backported the test setup from master, so it'll be easier to 
> add changes like this to Emacs 29.2 in the future.

Thanks, but it looks like you forgot to push...





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-21 14:23                               ` Eli Zaretskii
@ 2023-11-21 14:27                                 ` Dmitry Gutov
  0 siblings, 0 replies; 22+ messages in thread
From: Dmitry Gutov @ 2023-11-21 14:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: noah.v.peart, casouri, 67031-done

On 21/11/2023 16:23, Eli Zaretskii wrote:
>> Date: Tue, 21 Nov 2023 16:09:34 +0200
>> Cc:casouri@gmail.com,67031-done@debbugs.gnu.org
>> From: Dmitry Gutov<dmitry@gutov.dev>
>>
>> Version: 29.2
>>
>> On 21/11/2023 13:44, Eli Zaretskii wrote:
>>>> From: Noah Peart<noah.v.peart@gmail.com>
>>>> Date: Mon, 20 Nov 2023 20:41:49 -0800
>>>> Cc: Dmitry Gutov<dmitry@gutov.dev>,casouri@gmail.com,67031@debbugs.gnu.org
>>>>
>>>> I believe my copyright assignment is on file - Eli, I think you checked for me
>>>> last month.
>>> Yes, sorry, my bad.  I was coffee-challenged and therefore confused.
>>>
>>> So we can install this right away.
>> Thanks, installed.
>>
>> I've also backported the test setup from master, so it'll be easier to
>> add changes like this to Emacs 29.2 in the future.
> Thanks, but it looks like you forgot to push...

Ah thanks. The first try failed due to conflict.





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-20 18:13                   ` Noah Peart
  2023-11-20 22:28                     ` Dmitry Gutov
@ 2023-11-25  3:46                     ` Yuan Fu
  2023-11-25  3:48                       ` Yuan Fu
  1 sibling, 1 reply; 22+ messages in thread
From: Yuan Fu @ 2023-11-25  3:46 UTC (permalink / raw)
  To: Noah Peart; +Cc: Dmitry Gutov, Eli Zaretskii, 67031



> On Nov 20, 2023, at 10:13 AM, Noah Peart <noah.v.peart@gmail.com> wrote:
> 
> Sorry, ignore the previous patch.  A couple additional rules were needed to handle 
> "while" and "else".
> 
> On Mon, Nov 20, 2023 at 10:07 AM Noah Peart <noah.v.peart@gmail.com> wrote:
> Here is an updated patch with the added "else_clause" and indentation test for 
> statements without braces.
> 
> On Mon, Nov 20, 2023 at 4:55 AM Noah Peart <noah.v.peart@gmail.com> wrote:
> Yea, I'm using the same.  But, would it be useful to have a way to set that when 
> running tests without needing to temporarily add set `treesit-extra-load-path` in 
> the test file?
> 
> On Sun, Nov 19, 2023 at 5:38 AM Dmitry Gutov <dmitry@gutov.dev> wrote:
> On 19/11/2023 08:08, Eli Zaretskii wrote:
> >> Date: Sun, 19 Nov 2023 03:24:49 +0200
> >> Cc:casouri@gmail.com,67031@debbugs.gnu.org
> >> From: Dmitry Gutov<dmitry@gutov.dev>
> >>
> >> On 19/11/2023 02:12, Noah Peart wrote:
> >>> Yea, I can do that.
> >>>
> >>> Is there a recipe for running the tests with a tree-sitter library path?
> >> You mean with the default tree-sitter librayr path overridden? I'm not sure.
> > Why would an ERT test need that?  We are supposed to test Emacs with
> > the otherwise installed system features.  As tree-sitter grammars are
> > not part of Emacs, there should be no need to tell Emacs to use a
> > grammar library other than the one installed on the system.  Right?
> 
> We have a way to override that with the variable 
> treesit-extra-load-path, so it follows that some users will take 
> advantage of it to add extra directories.
> 
> I'm using ~/.emacs.d/tree-sitter/ myself.
> <typescript-ts-mode-indentation.patch>

That’s great! Is there anything else blocking us from applying this patch? Does Noah have the copyright assignment?

Yuan






^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements
  2023-11-25  3:46                     ` Yuan Fu
@ 2023-11-25  3:48                       ` Yuan Fu
  0 siblings, 0 replies; 22+ messages in thread
From: Yuan Fu @ 2023-11-25  3:48 UTC (permalink / raw)
  To: Noah Peart; +Cc: Dmitry Gutov, Eli Zaretskii, 67031


> On Nov 24, 2023, at 7:46 PM, Yuan Fu <casouri@gmail.com> wrote:
> 
> 
> 
>> On Nov 20, 2023, at 10:13 AM, Noah Peart <noah.v.peart@gmail.com> wrote:
>> 
>> Sorry, ignore the previous patch.  A couple additional rules were needed to handle 
>> "while" and "else".
>> 
>> On Mon, Nov 20, 2023 at 10:07 AM Noah Peart <noah.v.peart@gmail.com> wrote:
>> Here is an updated patch with the added "else_clause" and indentation test for 
>> statements without braces.
>> 
>> On Mon, Nov 20, 2023 at 4:55 AM Noah Peart <noah.v.peart@gmail.com> wrote:
>> Yea, I'm using the same.  But, would it be useful to have a way to set that when 
>> running tests without needing to temporarily add set `treesit-extra-load-path` in 
>> the test file?
>> 
>> On Sun, Nov 19, 2023 at 5:38 AM Dmitry Gutov <dmitry@gutov.dev> wrote:
>> On 19/11/2023 08:08, Eli Zaretskii wrote:
>>>> Date: Sun, 19 Nov 2023 03:24:49 +0200
>>>> Cc:casouri@gmail.com,67031@debbugs.gnu.org
>>>> From: Dmitry Gutov<dmitry@gutov.dev>
>>>> 
>>>> On 19/11/2023 02:12, Noah Peart wrote:
>>>>> Yea, I can do that.
>>>>> 
>>>>> Is there a recipe for running the tests with a tree-sitter library path?
>>>> You mean with the default tree-sitter librayr path overridden? I'm not sure.
>>> Why would an ERT test need that?  We are supposed to test Emacs with
>>> the otherwise installed system features.  As tree-sitter grammars are
>>> not part of Emacs, there should be no need to tell Emacs to use a
>>> grammar library other than the one installed on the system.  Right?
>> 
>> We have a way to override that with the variable 
>> treesit-extra-load-path, so it follows that some users will take 
>> advantage of it to add extra directories.
>> 
>> I'm using ~/.emacs.d/tree-sitter/ myself.
>> <typescript-ts-mode-indentation.patch>
> 
> That’s great! Is there anything else blocking us from applying this patch? Does Noah have the copyright assignment?

Never mind, just saw the follow-up. My email client’s threading has been messed up and some messages ended up in different threads :-(

Yuan




^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-11-25  3:48 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-10  1:29 bug#67031: [PATCH] Fix typescript-ts-mode indentation in unbracketed statements nvp
2023-11-15 13:40 ` Eli Zaretskii
2023-11-16  1:18   ` Dmitry Gutov
2023-11-18 10:05     ` Eli Zaretskii
2023-11-19  0:12       ` Noah Peart
2023-11-19  1:24         ` Dmitry Gutov
2023-11-19  6:08           ` Eli Zaretskii
2023-11-19  7:19             ` Noah Peart
2023-11-19 13:38             ` Dmitry Gutov
2023-11-20 12:55               ` Noah Peart
2023-11-20 18:07                 ` Noah Peart
2023-11-20 18:13                   ` Noah Peart
2023-11-20 22:28                     ` Dmitry Gutov
2023-11-21  3:27                       ` Eli Zaretskii
2023-11-21  4:41                         ` Noah Peart
2023-11-21 11:44                           ` Eli Zaretskii
2023-11-21 14:09                             ` Dmitry Gutov
2023-11-21 14:23                               ` Eli Zaretskii
2023-11-21 14:27                                 ` Dmitry Gutov
2023-11-25  3:46                     ` Yuan Fu
2023-11-25  3:48                       ` Yuan Fu
2023-11-19  4:26       ` Yuan Fu

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.