GNU bug report logs -
#61923
30.0.50; go-ts-mode, multiline raw-string-literal wrong indentation
Previous Next
Reported by: Gleb Zakharov <snyssfx <at> posteo.net>
Date: Thu, 2 Mar 2023 22:21:01 UTC
Severity: normal
Found in version 30.0.50
Fixed in version 29.1
Done: Dmitry Gutov <dmitry <at> gutov.dev>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Sun, 26 Nov 2023 18:37:00 +0200
with message-id <05ad3eeb-f756-07dc-6623-8cc1af35955c <at> gutov.dev>
and subject line Re: bug#61923: 30.0.50; go-ts-mode, multiline raw-string-literal wrong indentation
has caused the debbugs.gnu.org bug report #61923,
regarding 30.0.50; go-ts-mode, multiline raw-string-literal wrong indentation
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
61923: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61923
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Hi everyone,
thank you all for the hard work!
In Go, I sometimes work with code written in another language.
I embed it into Go as string literals, for example, SQL code.
When I type a multiline string, I notice that tree-sitter indents it by
usual Go rules, but this feature should be turned off inside the string.
How to reproduce the behavior with `emacs -Q`:
Paste a text from a snippet below, execute lines in the comments
to start `go-ts-mode` and
type M-q or M-x prog-fill-reindent-defun RET.
The text should stay as it is, but things in a multiline string
indented.
```
// (require 'treesit)
// (require 'go-ts-mode)
// (setq treesit-extra-load-path '("/home/snyssfx/.guix-home/profile/lib/tree-sitter"))
// (go-ts-mode)
func a() {
_ = `
SELECT a
FROM b
WHERE c;
if true {
panic("doesn't have to be indented")
}`
}
```
I tried to add
```
((node-is "raw-string-literal")
point-min)
```
to `go-ts-mode--indent-rules`, but it doesn't seem to fix it.
The problem doesn't exist for just string literals, as they must not be multiline.
Configured using:
'configure
CONFIG_SHELL=/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash
SHELL=/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash
--prefix=/gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87
--enable-fast-install --with-modules --with-cairo
--with-native-compilation --disable-build-details'
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE XIM XINPUT2 XPM
GTK3 ZLIB
Important settings:
value of $EMACSLOADPATH: /home/snyssfx/.guix-home/profile/share/emacs/site-lisp:/home/snyssfx/.guix-home/profile/share/emacs/site-lisp:/gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp
value of $LANG: en_US.utf8
locale-coding-system: utf-8-unix
Major mode: Go
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
/gnu/store/bswj8m0vr5pxxqz596wg1vw0l3vhap56-emacs-transient-20230219.1111/share/emacs/site-lisp/transient-20230219.1111/transient hides /gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp/transient
/gnu/store/nk42g92xzs9c0406xhkg7fq1iyijcn74-emacs-bind-key-20230203.2004/share/emacs/site-lisp/bind-key-20230203.2004/bind-key hides /gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp/use-package/bind-key
/gnu/store/zvamp8ayqg4867dc53mfk0ckjj277ryf-emacs-use-package-20230203.2004/share/emacs/site-lisp/use-package-20230203.2004/use-package hides /gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp/use-package/use-package
/gnu/store/zvamp8ayqg4867dc53mfk0ckjj277ryf-emacs-use-package-20230203.2004/share/emacs/site-lisp/use-package-20230203.2004/use-package-delight hides /gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp/use-package/use-package-delight
/gnu/store/zvamp8ayqg4867dc53mfk0ckjj277ryf-emacs-use-package-20230203.2004/share/emacs/site-lisp/use-package-20230203.2004/use-package-diminish hides /gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp/use-package/use-package-diminish
/gnu/store/zvamp8ayqg4867dc53mfk0ckjj277ryf-emacs-use-package-20230203.2004/share/emacs/site-lisp/use-package-20230203.2004/use-package-lint hides /gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp/use-package/use-package-lint
/gnu/store/zvamp8ayqg4867dc53mfk0ckjj277ryf-emacs-use-package-20230203.2004/share/emacs/site-lisp/use-package-20230203.2004/use-package-bind-key hides /gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp/use-package/use-package-bind-key
/gnu/store/zvamp8ayqg4867dc53mfk0ckjj277ryf-emacs-use-package-20230203.2004/share/emacs/site-lisp/use-package-20230203.2004/use-package-jump hides /gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp/use-package/use-package-jump
/gnu/store/zvamp8ayqg4867dc53mfk0ckjj277ryf-emacs-use-package-20230203.2004/share/emacs/site-lisp/use-package-20230203.2004/use-package-ensure hides /gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp/use-package/use-package-ensure
/gnu/store/zvamp8ayqg4867dc53mfk0ckjj277ryf-emacs-use-package-20230203.2004/share/emacs/site-lisp/use-package-20230203.2004/use-package-core hides /gnu/store/xa55f4sq86q91l59c5nwmhch75s82icp-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp/use-package/use-package-core
Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date smerge-mode
diff-mode easy-mmode diff help-fns radix-tree cl-print byte-opt debug
backtrace find-func go-ts-mode treesit cl-loaddefs comp comp-cstr
warnings icons subr-x rx cl-seq cl-macs gv cl-extra help-mode bytecomp
byte-compile cl-lib rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process
native-compile emacs)
Memory information:
((conses 16 97206 10432)
(symbols 48 8202 0)
(strings 32 23985 1962)
(string-bytes 1 788970)
(vectors 16 18947)
(vector-slots 8 370311 8362)
(floats 8 50 38)
(intervals 56 629 0)
(buffers 984 16))
[Message part 3 (message/rfc822, inline)]
Version: 29.1
On 26/11/2023 17:47, Jens Schmidt via Bug reports for GNU Emacs, the
Swiss army knife of text editors wrote:
> Gleb Zakharov<snyssfx <at> posteo.net> writes:
>
>> Dmitry Gutov<dgutov <at> yandex.ru> writes:
>>
>>> This seems to work:
>>>
>>> diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
>>> index e8f93d14744..1857c67bb82 100644
>>> --- a/lisp/progmodes/go-ts-mode.el
>>> +++ b/lisp/progmodes/go-ts-mode.el
>>> @@ -71,6 +71,7 @@ go-ts-mode--indent-rules
>>> ((node-is "]") parent-bol 0)
>>> ((node-is "}") parent-bol 0)
>>> ((node-is "labeled_statement") no-indent)
>>> + ((parent-is "raw_string_literal") no-indent)
>>> ((parent-is "argument_list") parent-bol go-ts-mode-indent-offset)
>>> ((parent-is "block") parent-bol go-ts-mode-indent-offset)
>>> ((parent-is "communication_case") parent-bol
>>> go-ts-mode-indent-offset)
>> Thank you, it works for me as well!
> It seems that this bug could be closed: AFAICT the fix is installed on
> master and Gleb was happy with it.
Closing!
This bug report was last modified 1 year and 179 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.