GNU bug report logs -
#75774
30.0.92; `treesit-thing-settings' not set properly for typescript-ts-mode
Previous Next
Reported by: errelinaaron <at> gmail.com
Date: Thu, 23 Jan 2025 05:11:02 UTC
Severity: normal
Found in version 30.0.92
Fixed in version 31.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75774 in the body.
You can then email your comments to 75774 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75774
; Package
emacs
.
(Thu, 23 Jan 2025 05:11:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
errelinaaron <at> gmail.com
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 23 Jan 2025 05:11:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: errelinaaron <at> gmail.com
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.92; treesit-thing-settings not set properly for typescript-ts-mode
X-Debbugs-Cc:
--text follows this line--
While using the shipped typescript-ts-mode to edit a typescript file, I
found I cannot use `C-M-f' to forward sexpressions as I usually do with
other major modes (e.g. c-ts-mode, rust-mode, etc). For example, given
the following code snippet
import { Chain } from './common'
^
If I put my point under the opening `{' and press `C-M-f', the point
will move immediately after `Chain', instead of at the closing `}'.
Here is another example:
constructor(url: string) {
console.log('SuiTransport', url)
If I put the pointer under the first `(' after the word `constructor',
and then press `C-M-f', the pointer will move to the `:' after
`url'. However, forwarding sexp works for the parentheses after `log'.
I tried to search through the Emacs manual and found the most likely
relevant variable `treesit-thing-settings`, which has a default,
local-to-buffer value for typescript-ts-mode as below:
((typescript
(sexp
"\\(?:ar\\(?:guments\\|ray\\)\\|e\\(?:scape\\|xpression\\)\\|f\\(?:alse\\|unction\\)\\|identifier\\|nu\\(?:ll\\|mber\\)\\|pa\\(?:ir\\|ttern\\)\\|regex\\|s\\(?:tring\\|uper\\)\\|t\\(?:emplate\\|his\\|rue\\)\\|undefined\\)")
(sentence
"\\(?:break_statement\\|continue_statement\\|d\\(?:\\(?:ebugger\\|o\\)_statement\\)\\|e\\(?:\\(?:mpty\\|xpression\\)_statement\\)\\|for_\\(?:\\(?:in_\\)?statement\\)\\|i\\(?:\\(?:f\\|mport\\)_statement\\)\\|l\\(?:abeled_statement\\|exical_declaration\\)\\|property_signature\\|return_statement\\|switch_statement\\|t\\(?:\\(?:hrow\\|ry\\)_statement\\)\\|variable_declaration\\|w\\(?:\\(?:hile\\|ith\\)_statement\\)\\)")
(text "\\(?:comment\\|template_string\\)")))
This does explain the behavior I have experienced so far: since
`arguments', `identifier' are all recognized as sexp, the pointer
moves to and stops after them, which is really not intuitive compared to the
more common Emacs's view of sexp: expressions with balanced structures.
In contrast, the c-ts-mode has set `treesit-thing-settings' to the
following value:
(setq treesit-thing-settings
'((typescript . ((sexp . (not "[](),[{}]"))
(sentence
. "\\(import_statement\\|expression_statement\\|declaration\\)")))))
I think this makes more sense. Considering that typescript's syntax is
predominantly C-like and it's very common to move between `{}', `()',
`[]', `""',
`''', May I ask if it is possible to make the default value of
`treesit-thing-settings' for typescript-ts-mode to act more like, (if
not exactly the same as), to that of the traditional
`forward-sexp-function'?
Best regards,
Errlin
In GNU Emacs 30.0.92 (build 2, x86_64-pc-linux-gnu)
Repository revision: 80cddfaaea3058fe70fc73ba3d267ad1c884bd3d
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12401004
System Description: Arch Linux
Configured using:
'configure --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib
--localstatedir=/var --with-tree-sitter --with-harfbuzz
--with-libsystemd --with-modules --with-jpeg --with-png --with-rsvg
--without-cairo --without-gpm --without-sound --disable-build-details
--with-x-toolkit=no --without-toolkit-scroll-bars --without-gsettings
'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
-Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security
-fstack-clash-protection -fcf-protection -fno-omit-frame-pointer
-mno-omit-leaf-frame-pointer -g
-ffile-prefix-map=/home/noel/projects/pkgbuilds/app-editors/emacs/src=/usr/src/debug/emacs
-flto=auto' 'LDFLAGS=-Wl,-O1 -Wl,--sort-common -Wl,--as-needed
-Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto''
Configured features:
ACL DBUS FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LCMS2 LIBOTF
LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY OLDXMENU
PDUMPER PNG RSVG SECCOMP SQLITE3 THREADS TIFF TREE_SITTER WEBP X11 XDBE
XFT XIM XINPUT2 XPM ZLIB
Important settings:
value of $LC_TIME: en_AU.UTF-8
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: TypeScript
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
minibuffer-regexp-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:
None found.
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 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 cl-extra pp cl-print thingatpt
help-fns radix-tree help-mode compile text-property-search comint
ansi-osc ansi-color ring comp-run comp-common rx cl-seq
typescript-ts-mode js c-ts-common json subr-x map byte-opt gv bytecomp
byte-compile imenu cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs treesit vc-git diff-mode
track-changes easy-mmode vc-dispatcher cl-loaddefs 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
touch-screen 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 font-render-setting
xinput2 x multi-tty move-toolbar make-network-process native-compile
emacs)
Memory information:
((conses 16 132999 13414) (symbols 48 10422 0) (strings 32 32345 2933)
(string-bytes 1 1113270) (vectors 16 16978)
(vector-slots 8 213223 8287) (floats 8 70 2) (intervals 56 503 4)
(buffers 992 13))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75774
; Package
emacs
.
(Thu, 23 Jan 2025 07:32:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 75774 <at> debbugs.gnu.org (full text, mbox):
close 75774 31.0.50
thanks
> This does explain the behavior I have experienced so far: since
> `arguments', `identifier' are all recognized as sexp, the pointer
> moves to and stops after them, which is really not intuitive compared to the
> more common Emacs's view of sexp: expressions with balanced structures.
In Emacs 31 this is already fixed by defining balanced structures
in treesit-thing-settings for typescript-ts-mode.
bug marked as fixed in version 31.0.50, send any further explanations to
75774 <at> debbugs.gnu.org and errelinaaron <at> gmail.com
Request was from
Juri Linkov <juri <at> linkov.net>
to
control <at> debbugs.gnu.org
.
(Thu, 23 Jan 2025 07:32:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75774
; Package
emacs
.
(Thu, 23 Jan 2025 08:19:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 75774 <at> debbugs.gnu.org (full text, mbox):
Hi Juri,
Glad to know it gets fixed in a future release, though I wish it could
be fixed in Emacs 30.1.
But I understand there might be non-trivial work for the fix. For now
I can get by and modify the variable in my
persone config. Thank you for the reply and all the best.
Best,
Errelin
On Thu, Jan 23, 2025 at 6:30 PM Juri Linkov <juri <at> linkov.net> wrote:
>
> close 75774 31.0.50
> thanks
>
> > This does explain the behavior I have experienced so far: since
> > `arguments', `identifier' are all recognized as sexp, the pointer
> > moves to and stops after them, which is really not intuitive compared to the
> > more common Emacs's view of sexp: expressions with balanced structures.
>
> In Emacs 31 this is already fixed by defining balanced structures
> in treesit-thing-settings for typescript-ts-mode.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75774
; Package
emacs
.
(Thu, 23 Jan 2025 09:25:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 75774 <at> debbugs.gnu.org (full text, mbox):
> Cc: 75774 <at> debbugs.gnu.org
> From: Noel Errenil <errelinaaron <at> gmail.com>
> Date: Thu, 23 Jan 2025 19:18:10 +1100
>
> Hi Juri,
>
> Glad to know it gets fixed in a future release, though I wish it could
> be fixed in Emacs 30.1.
It's too late for non-trivial changes in what will soon become Emacs
30.1, sorry.
If the fix is important, and the changes are safe enough, we could
consider this for Emacs 30.2.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75774
; Package
emacs
.
(Thu, 23 Jan 2025 09:43:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 75774 <at> debbugs.gnu.org (full text, mbox):
Hi Eli,
Thanks for the information. I totally understand that. I'm happy with
whatever decision(s)
made on this. The variable is configurable at the moment so I can get
by. Really appreciate
your help and work.
Best wishes,
Errelin
On Thu, Jan 23, 2025 at 8:23 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > Cc: 75774 <at> debbugs.gnu.org
> > From: Noel Errenil <errelinaaron <at> gmail.com>
> > Date: Thu, 23 Jan 2025 19:18:10 +1100
> >
> > Hi Juri,
> >
> > Glad to know it gets fixed in a future release, though I wish it could
> > be fixed in Emacs 30.1.
>
> It's too late for non-trivial changes in what will soon become Emacs
> 30.1, sorry.
>
> If the fix is important, and the changes are safe enough, we could
> consider this for Emacs 30.2.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 20 Feb 2025 12:24:15 GMT)
Full text and
rfc822 format available.
This bug report was last modified 175 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.