Subject: 30.1; java-ts-mode treesit-thing-settings missing case

From: Errenil Noel <[email-masked]>
Date: Sun, 23 Feb 2025 14:27:34 +1100

When editing Java source code files with `java-ts-mode`, I found the
following two cases are not correctly handled by `mark-sexp` (bound to
`C-M-SPC`):

Case 1: formal_parameters

    void getUserInfo(String name, int age) { ... }

Put the point under `g` in the function name and try to mark the sexp,
the expected behavior is Emacs first marks `getUserInfo` and then
gradually mark the entire `getUserInfo(String name, int age)`.  But at
the moment, the point stops right _after_ `age`, without including the
closing parenthesis `)`.

As I understand it, the reason for this might be that
`"formal_parameters"` node has not been included in the `sexp` group for
java-ts-mode's `treesit-thing-settings`

Case 2: type casting

     return (double)age

Put the point under `r` in `return` and try to start marking sexp, the
point stops after `double`, without marking the closing `)` again. The
reason is likely to be the same as above, case casting case is not
included in `treesit-thing-settings`.

I'm not sure if this was overlooked or a concious decision made. I'm
just hoping that if possible, at least these two cases can be added to
the default `sexp` group in `treesit-thing-settings` for `java-ts-mode`,
so that users can get consistent experience using either the treesit
major mode or the long standing cc-mode. Thanks for advance.

In GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu)
Repository revision: ae297c2007a100f33d146b8f5f7832f708719e9b
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12401005
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_CTYPE: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: TS Explorer

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  server-mode: t
  windmove-mode: t
  company-tng-mode: t
  vertico-mode: t
  meow-global-mode: t
  meow-mode: t
  meow-motion-mode: t
  meow-esc-mode: t
  envrc-global-mode: t
  envrc-mode: t
  which-key-mode: t
  straight-use-package-mode: t
  straight-package-neutering-mode: t
  straight-live-modifications-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/noel/.emacs.d/straight/build/which-key/which-key hides /usr/share/emacs/30.1/lisp/which-key
/home/noel/.emacs.d/straight/build/transient/transient hides /usr/share/emacs/30.1/lisp/transient
/home/noel/.emacs.d/straight/build/jsonrpc/jsonrpc hides /usr/share/emacs/30.1/lisp/jsonrpc
/home/noel/.emacs.d/straight/build/external-completion/external-completion hides /usr/share/emacs/30.1/lisp/external-completion
/home/noel/.emacs.d/straight/build/xref/xref hides /usr/share/emacs/30.1/lisp/progmodes/xref
/home/noel/.emacs.d/straight/build/project/project hides /usr/share/emacs/30.1/lisp/progmodes/project
/home/noel/.emacs.d/straight/build/flymake/flymake hides /usr/share/emacs/30.1/lisp/progmodes/flymake
/home/noel/.emacs.d/straight/build/eglot/eglot hides /usr/share/emacs/30.1/lisp/progmodes/eglot
/home/noel/.emacs.d/straight/build/seq/seq hides /usr/share/emacs/30.1/lisp/emacs-lisp/seq
/home/noel/.emacs.d/straight/build/map/map hides /usr/share/emacs/30.1/lisp/emacs-lisp/map
/home/noel/.emacs.d/straight/build/let-alist/let-alist hides /usr/share/emacs/30.1/lisp/emacs-lisp/let-alist
/home/noel/.emacs.d/straight/build/eldoc/eldoc hides /usr/share/emacs/30.1/lisp/emacs-lisp/eldoc
/home/noel/.emacs.d/straight/build/compat/compat hides /usr/share/emacs/30.1/lisp/emacs-lisp/compat

Features:
(shadow sort mail-extr emacsbug xref tramp-cache time-stamp tramp-sh
shortdoc oc-basic ol-eww eww url-queue mm-url ol-rmail ol-mhe ol-irc
ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view mml-smime smime
gnutls dig gnus-sum shr pixel-fill kinsoku url-file svg dom gnus-group
gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail
mail-source utf7 nnoo gnus-spec gnus-int gnus-range gnus-win gnus
nnheader range ol-docview doc-view jka-compr image-mode exif ol-bibtex
bibtex ol-bbdb ol-w3m ol-doi org-link-doi ob-clojure ob-shell gptel-org
org-element org-persist org-id org-refile org-element-ast inline
avl-tree generator org ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-macro org-src sh-script smie executable ob-comint org-pcomplete
org-list org-footnote org-faces org-entities ob-emacs-lisp ob-core
ob-eval org-cycle org-table ol org-fold org-fold-core org-keys oc
org-loaddefs cal-menu calendar cal-loaddefs org-version org-compat
org-macs vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view
bug-reference face-remap magit-submodule magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone
magit-remote magit-commit magit-sequence magit-notes magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit package url-handlers magit-repos magit-apply
magit-wip magit-log which-func imenu magit-diff smerge-mode diff
git-commit log-edit message sendmail puny rfc822 mml mml-sec gnus-util
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader
pcvs-util add-log magit-core magit-autorevert autorevert filenotify
magit-margin magit-transient magit-process magit-mode browse-url
benchmark magit-git magit-base magit-section cursor-sensor crm llama
make-mode help-fns radix-tree cl-print debug backtrace find-func eat
term/xterm xterm tramp trampver tramp-integration tramp-message
tramp-compat xdg parse-time iso8601 tramp-loaddefs term disp-table ehelp
misearch multi-isearch hippie-exp rg files-x vc rg-info-hack rg-menu
transient rg-ibuffer rg-result wgrep-rg wgrep rg-history rg-header
ibuf-ext ibuffer ibuffer-loaddefs grep cus-edit cus-start cus-load
wid-edit dired-aux dired dired-loaddefs pulse gptel-curl flyspell ispell
yank-media markdown-mode noutline outline epa-file epa derived epg
rfc6068 epg-config password-store auth-source-pass with-editor comp
comp-cstr warnings shell pcomplete server compile comint ansi-osc ring
comp-run comp-common gptel-context windmove orderless time-date
java-ts-mode c-ts-common vc-git vc-dispatcher pp project paredit edmacro
highlight-defined advice elec-pair yasnippet company-keywords
company-dabbrev-code company-dabbrev company-files company-capf
company-tng company lang-dsl zk format-spec thingatpt lang-web
lang-script lang-go lang-clike lang-rust lang-fp lang-lisps
clojure-ts-mode-autoloads init-git init-paredit init-completion treesit
vertico init-meow meow meow-tutor meow-cheatsheet meow-cheatsheet-layout
meow-core meow-shims delsel meow-esc meow-command array meow-thing
meow-visual pcase meow-keypad meow-beacon kmacro meow-helpers meow-util
color meow-keymap meow-face meow-var init-gui chacha-theme init-utils
envrc inheritenv diff-mode track-changes easy-mmode ansi-color which-key
gptel-anthropic gptel text-property-search url url-proxy url-privacy
url-expand url-methods url-history url-cookie generate-lisp-file
url-domsuf url-util url-parse auth-source eieio eieio-core icons
password-cache json url-vars mailcap compat gptel-openai map byte-opt
init-options init-packages which-key-autoloads envrc-autoloads
inheritenv-autoloads vundo-autoloads vertico-autoloads
symbol-overlay-autoloads highlight-defined-autoloads jstx-autoloads
zk-autoloads typst-ts-mode-autoloads rust-mode-autoloads cargo-autoloads
emmet-mode-autoloads tide-autoloads svelte-mode-autoloads
sqlup-mode-autoloads rg-autoloads wgrep-autoloads pass-autoloads
password-store-otp-autoloads password-store-autoloads paredit-autoloads
company-coq-autoloads company-math-autoloads math-symbol-lists-autoloads
proof-general-autoloads proof-site proof-autoloads orderless-autoloads
nix-mode-autoloads move-mode-autoloads meow-autoloads hindent-autoloads
forge-autoloads yaml-autoloads magit-autoloads with-editor-autoloads
magit-section-autoloads ghub-autoloads treepy-autoloads llama-autoloads
let-alist-autoloads closql-autoloads emacsql-autoloads
flymake-hlint-autoloads flymake-easy-autoloads haskell-mode-autoloads
flycheck-pos-tip-autoloads pos-tip-autoloads
flycheck-clj-kondo-autoloads flycheck-autoloads lsp-mode-autoloads
lv-autoloads markdown-mode-autoloads ht-autoloads f-autoloads
s-autoloads dash-autoloads justl.el-autoloads just-mode-autoloads
json-mode-autoloads rx json-snatcher-autoloads gptel-autoloads
geiser-mit-autoloads geiser-chez-autoloads geiser-guile-autoloads
geiser-chicken-autoloads geiser-autoloads go-mode.el-autoloads
eat-autoloads eglot-booster-autoloads eglot-autoloads flymake-autoloads
project-autoloads xref-autoloads external-completion-autoloads
eldoc-autoloads jsonrpc-autoloads emacs-ccls-autoloads embark-autoloads
consult-autoloads company-auctex-autoloads yasnippet-autoloads
company-autoloads corfu-autoloads citre-autoloads cider-autoloads
transient-autoloads sesman-autoloads spinner-autoloads queue-autoloads
finder-inf parseedn-autoloads map-autoloads parseclj-autoloads
clojure-mode-autoloads cape-autoloads compat-autoloads seq-autoloads
auctex-latexmk-autoloads auctex-lua-autoloads lua-mode-autoloads
auctex-autoloads tex-site info early-init init-straight
straight-autoloads cl-seq cl-extra help-mode straight subr-x cl-macs gv
cl-loaddefs cl-lib bytecomp byte-compile 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 787871 197978) (symbols 48 42986 11)
 (strings 32 166854 10125) (string-bytes 1 6433039) (vectors 16 78616)
 (vector-slots 8 1295212 75774) (floats 8 754 10329)
 (intervals 56 15452 5086) (buffers 992 49))