unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#70023: [PATCH] Add typescript-ts-mode indentation for interface bodies
@ 2024-03-27  6:20 Noah Peart
  2024-03-28 13:11 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-03-28 18:10 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 4+ messages in thread
From: Noah Peart @ 2024-03-27  6:20 UTC (permalink / raw)
  To: 70023


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

Tags: patch


Adds missing indentation for typescript interfaces.

Currently, there is no indentation for property signatures in typescript
interfaces.

To reproduce, call `M-x (my-test-typescript-indent)`

    (defun my-test-typescript-indent ()
      (interactive)
      (typescript-ts-mode)
      (setq-local typescript-ts-mode-indent-offset 4)
      (indent-region (point-min) (point-max)))


in buffer with the following typescript code:

    interface Foo {
    foo: string;   // no matching indent rule
    bar?: boolean; // no matching indent rule
    }


In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2024-03-24 built on noah-X580VD
Repository revision: c5de73a95a6ecefe46fe1ac07da8e83032be7f5b
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.4 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: 1366 bytes --]

[-- Attachment #2: 0001-Add-typescript-ts-mode-indentation-for-interface-bod.patch --]
[-- Type: text/x-patch, Size: 1270 bytes --]

From a39f2364973998318b56d91cb2801a06b237b88a Mon Sep 17 00:00:00 2001
From: Noah Peart <noah.v.peart@gmail.com>
Date: Tue, 26 Mar 2024 22:44:48 -0700
Subject: [PATCH] Add typescript-ts-mode indentation for interface bodies

* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--indent-rules): Add indentation rule for
interface bodies.
---
 lisp/progmodes/typescript-ts-mode.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index ea4f6417c5a..ab1d76ab20e 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -124,6 +124,7 @@ typescript-ts-mode--indent-rules
      ((parent-is "object_type") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "enum_body") parent-bol typescript-ts-mode-indent-offset)
      ((parent-is "class_body") parent-bol typescript-ts-mode-indent-offset)
+     ((parent-is "interface_body") parent-bol typescript-ts-mode-indent-offset)
      ((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)
-- 
2.34.1


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

* bug#70023: [PATCH] Add typescript-ts-mode indentation for interface bodies
  2024-03-27  6:20 bug#70023: [PATCH] Add typescript-ts-mode indentation for interface bodies Noah Peart
@ 2024-03-28 13:11 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-03-28 14:31   ` Eli Zaretskii
  2024-03-28 18:10 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 4+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-28 13:11 UTC (permalink / raw)
  To: Noah Peart; +Cc: 70023

Noah Peart <noah.v.peart@gmail.com> writes:

> Tags: patch
>
> Adds missing indentation for typescript interfaces.
>
> Currently, there is no indentation for property signatures in typescript
> interfaces.
>
> To reproduce, call `M-x (my-test-typescript-indent)`
>
>     (defun my-test-typescript-indent ()
>       (interactive)
>       (typescript-ts-mode)
>       (setq-local typescript-ts-mode-indent-offset 4)
>       (indent-region (point-min) (point-max)))
>
> in buffer with the following typescript code:
>
>     interface Foo {
>     foo: string;   // no matching indent rule
>     bar?: boolean; // no matching indent rule
>     }


Thanks - This looks good to me. Have you contributed to emacs earlier? I
think this could go in regardless as it is a trivial addition, or what,
Eli?

I'll install it on emacs-29 later today if noone cries out :-)

Theo





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

* bug#70023: [PATCH] Add typescript-ts-mode indentation for interface bodies
  2024-03-28 13:11 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-03-28 14:31   ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2024-03-28 14:31 UTC (permalink / raw)
  To: Theodor Thornhill; +Cc: noah.v.peart, 70023

> Cc: 70023@debbugs.gnu.org
> Date: Thu, 28 Mar 2024 14:11:33 +0100
> From:  Theodor Thornhill via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Thanks - This looks good to me. Have you contributed to emacs earlier? I
> think this could go in regardless as it is a trivial addition, or what,
> Eli?

Noah has copyright assignment on file, so we can accept his
contributions without limitations.





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

* bug#70023: [PATCH] Add typescript-ts-mode indentation for interface bodies
  2024-03-27  6:20 bug#70023: [PATCH] Add typescript-ts-mode indentation for interface bodies Noah Peart
  2024-03-28 13:11 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-03-28 18:10 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 4+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-28 18:10 UTC (permalink / raw)
  To: Noah Peart; +Cc: 70023

Noah Peart <noah.v.peart@gmail.com> writes:

> Tags: patch
>
> Adds missing indentation for typescript interfaces.
>
> Currently, there is no indentation for property signatures in typescript
> interfaces.
>
> To reproduce, call `M-x (my-test-typescript-indent)`
>
>     (defun my-test-typescript-indent ()
>       (interactive)
>       (typescript-ts-mode)
>       (setq-local typescript-ts-mode-indent-offset 4)
>       (indent-region (point-min) (point-max)))
>

[...]

Pushed in bcf6dd6e266222a293e359430afdf3a2dc18369c. I also added a test
confirming the behavior.

As a small aside, this node type was added very recently. Until now we
had a rule for it in 'object'

Thanks!

Theo





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

end of thread, other threads:[~2024-03-28 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27  6:20 bug#70023: [PATCH] Add typescript-ts-mode indentation for interface bodies Noah Peart
2024-03-28 13:11 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-28 14:31   ` Eli Zaretskii
2024-03-28 18:10 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).