[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#61923: 30.0.50; go-ts-mode, multiline raw-string-literal wrong inden
From: |
Eli Zaretskii |
Subject: |
bug#61923: 30.0.50; go-ts-mode, multiline raw-string-literal wrong indentation |
Date: |
Fri, 03 Mar 2023 13:38:47 +0200 |
[Please always use Reply All to keep the bug address on the CC list.]
> From: Gleb Zakharov <snyssfx@posteo.net>
> Date: Fri, 03 Mar 2023 11:26:32 +0000
>
> Hi Eli,
> Thanks for the quick reply.
>
> Eli Zaretskii <eliz@gnu.org> writes:
> > Tweaking the language indentation
> > rules to cater for these quite specialized use cases is not TRT, IMO,
> > because it is likely to contradict what the majority of language users
> > want and expect.
>
> I'm not sure if you meant that the special case involves embedding other
> languages or simply using multi-line strings.
The latter. AFAIU, you suggested to change how multi-line strings are
indented because of the use case of embedding other languages there.
> While raw strings in Go can be used for various purposes,
> including the code of other languages, they can also be used for
> arbitrary text. The issue I'm facing is that when tabs are added by
> tree-sitter indentation, they become a part of the string, which can
> affect the program, for example if we want to compare strings with each
> other.
>
> Consider this example:
> ```
> // (require 'treesit)
> // (require 'go-ts-mode)
> // (setq treesit-extra-load-path
> '("/home/snyssfx/.guix-home/profile/lib/tree-sitter"))
> // (go-ts-mode)
>
> func a() {
> _ = `
> Lorem ipsum dolor sit amet,
> consectetur adipiscing elit,
> sed do eiusmod tempor incididunt ut
> labore et dolore magna aliqua.
> `
> }
> ```
>
> If I call M-q or make a change somewhere in the string, part of the text
> inside
> the string will be re-indented,
> which will result in additional \t symbols in the string literal.
>
> I can undo this indentation with C-/ though, which is how I do it now.
If you are saying that the indentation inside string is incorrect in
general, then I agree we should fix it. (I don't use Go.) But then
please present the reproduction recipe which doesn't use another
language in the string, but simply has a string, which is corrupted by
indentation.
> > This use case, and others
> > like it, are supposed to be handled by features that support multiple
> > major modes in the same buffer.
>
> Thanks for the tip, I will take a look, for example indirect buffers can
> certainly improve my experience here.
>
> Best Regards,
> Gleb
>