bug-gnu-emacs
[Top][All Lists]
Advanced

[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: Gleb Zakharov
Subject: bug#61923: 30.0.50; go-ts-mode, multiline raw-string-literal wrong indentation
Date: Fri, 03 Mar 2023 11:39:08 +0000

Sorry, forgot to add debbugs.gnu.org to the forward list.

-------------------- Start of forwarded message --------------------
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.

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.

> 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
-------------------- End of forwarded message --------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]