unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#60748: 30.0.50; [PATCH]: Fix indentation of object_expressions in csharp-ts-mode
@ 2023-01-12  8:15 Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-01-13 10:41 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-01-12  8:15 UTC (permalink / raw)
  To: 60748; +Cc: Jostein Kjønigsen

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


Hi Jostein!

What do you think of this patch?  It fixes typing out this, taken from
[0]:

```
namespace Foo {
    class Foo {
        void foo() {
            CatOwner owner = new CatOwner
            {
                Cats = new List<Cat>
                {
                    new X
                    {
                        Name = "Sylvester",
                        Age=8
                    },
                    new Cat
                    {
                        Name = "Whiskers", Age=2
                    },
                    new Cat
                    { Name = "Sasha", Age=14 }
                }
            };

            var x = new
            {
                X = 5
            };

            Foo foo = new Foo
            {
            };

            Cat cat = new Cat
            {
                Cats = new List<Cat>
                {
                    new X
                    {
                        Name = "Sten"
                    },
                    new Y
                    { Foo = "rst" }
                }
            };

            Cat c = new Foo()
            {
                
            };

            RudimentaryMultiValuedDictionary<string, string> rudimentaryMultiValuedDictionary3
                = new RudimentaryMultiValuedDictionary<string, string>()
                {
                    {"Group1", new string []{ "Bob", "John", "Mary" } },
                    { "Group2", new string[]{ "Eric", "Emily", "Debbie", "Jesse" } }
                };
        }
    }
}
```

Are there any regressions, or is this ok to you?

Theo

[0]: 


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-indentation-of-object_expressions-in-csharp-ts-m.patch --]
[-- Type: text/x-patch, Size: 1429 bytes --]

From 6efac3cb4c19c50dfb3d9ab5218e88325ff19441 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Thu, 12 Jan 2023 09:06:45 +0100
Subject: [PATCH] Fix indentation of object_expressions in csharp-ts-mode

* lisp/progmodes/csharp-mode.el (csharp-ts-mode--indent-rules): Make
sure the opening brace is indented at parent-bol, and everything else
is indented.
---
 lisp/progmodes/csharp-mode.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index 79afd7f91d..81ce41618e 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -640,6 +640,11 @@ compilation and evaluation time conflicts."
      ((parent-is "namespace_declaration") parent-bol 0)
      ((parent-is "class_declaration") parent-bol 0)
      ((parent-is "constructor_declaration") parent-bol 0)
+     ((parent-is "initializer_expression") parent-bol csharp-ts-mode-indent-offset)
+     ((match "{" "anonymous_object_creation_expression") parent-bol 0)
+     ((parent-is "anonymous_object_creation_expression") parent-bol csharp-ts-mode-indent-offset)
+     ((match "{" "object_creation_expression") parent-bol 0)
+     ((parent-is "object_creation_expression") parent-bol 0)
      ((parent-is "method_declaration") parent-bol 0)
      ((parent-is "enum_declaration") parent-bol 0)
      ((parent-is "operator_declaration") parent-bol 0)
-- 
2.34.1


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

end of thread, other threads:[~2023-01-13 11:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-12  8:15 bug#60748: 30.0.50; [PATCH]: Fix indentation of object_expressions in csharp-ts-mode Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-13 10:41 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-13 11:16   ` Jostein Kjønigsen
2023-01-13 11:42     ` 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).