Subject: bug#71205: 29.3; Automatic indentation of c-ts-mode doesn't work well for me.

From: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) <[email-masked]>
Date: Sun, 26 May 2024 13:32:37 +0900

Dear emacs-devel maintainers.

Automatic indentation of c-ts-mode doesn't work well for me.
I tried it in two environments, and neither worked properly.

- homebrew cask emacs 29.3 on MacBookAir M1 2020 Sonoma 14.4.1
- emacs 29.1 on FreeBSD 13.2-RELEASE-p3

I have elpa package `~/.emacs.d/elpa/treesit-auto-20240511.1425` .
I have the following language bundles in `~/.emacs.d/tree-sitter` on 
MacBookAir,

-rwxr-xr-x 1 XXXXX staff 664K  5 23 17:41 libtree-sitter-c.dylib
-rwxr-xr-x 1 XXXXX staff 3.8M  5 23 17:41 libtree-sitter-cpp.dylib
-rwxr-xr-x 1 XXXXX staff 648K  5 23 17:44 libtree-sitter-python.dylib

and on FreeBSD,

-rwxr-xr-x 1 XXXXX XXXXX 618K May 23 23:12 libtree-sitter-c.so
-rwxr-xr-x 1 XXXXX XXXXX 3.7M May 23 23:12 libtree-sitter-cpp.so

I have a simple `~/.emacs.d/init.el` the follows,

-------------- init.el begins ---------------------
(use-package treesit
   :config
   (setq treesit-font-lock-level 4))

(use-package treesit-auto
   :ensure t
   :config
   (setq treesit-auto-install t)
   (global-treesit-auto-mode))
---------------- init.el ends ---------------------

The steps to reproduce are as follows.

1. Start emacs.
2. Open the C source code file and write the following content.

----------- c source code file begins -------------
void test(void)
{
   do🔳
----------- c source code file ends ---------------

3. Place the cursor after `do` and press Return.

Expected behaviour is automatic indentation. I want to move the cursor 
to the 5th column of the next line.
However, the observed behavior is NOT indentation. The cursor moves to 
the 1st column of the next line.
For reference, the column position of `do` was moved correctly the 3rd 
column with automatic indentation.

Thanx.

In GNU Emacs 29.3 (build 1, aarch64-apple-darwin21.6.0, NS
  appkit-2113.60 Version 12.6.6 (Build 21G646)) of 2024-03-24 built on
  armbob.lan
Windowing system distributor 'Apple', version 10.3.2487
System Description:  macOS 14.4.1

Configured using:
  'configure --with-ns '--enable-locallisppath=/Library/Application
  Support/Emacs/${version}/site-lisp:/Library/Application
  Support/Emacs/site-lisp' --with-modules 'CFLAGS=-DFD_SETSIZE=10000
  -DDARWIN_UNLIMITED_SELECT' --with-x-toolkit=no'

Configured features:
ACL GLIB GMP GNUTLS JPEG JSON LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER
PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER ZLIB

Important settings:
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=uim
   locale-coding-system: utf-8-unix

Major mode: C/*

Minor modes in effect:
   global-treesit-auto-mode: t
   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:
/Users/kawamoto/.emacs.d/elpa/transient-20230120.1559/transient hides 
/Applications/Emacs.app/Contents/Resources/lisp/transient
/Users/kawamoto/.emacs.d/elpa/use-package-20210207.1926/use-package-jump 
hides 
/Applications/Emacs.app/Contents/Resources/lisp/use-package/use-package-jump
/Users/kawamoto/.emacs.d/elpa/use-package-20210207.1926/use-package-ensure 
hides 
/Applications/Emacs.app/Contents/Resources/lisp/use-package/use-package-ensure
/Users/kawamoto/.emacs.d/elpa/use-package-20210207.1926/use-package-core 
hides 
/Applications/Emacs.app/Contents/Resources/lisp/use-package/use-package-core
/Users/kawamoto/.emacs.d/elpa/use-package-20210207.1926/use-package-delight 
hides 
/Applications/Emacs.app/Contents/Resources/lisp/use-package/use-package-delight
/Users/kawamoto/.emacs.d/elpa/use-package-20210207.1926/use-package-diminish 
hides 
/Applications/Emacs.app/Contents/Resources/lisp/use-package/use-package-diminish
/Users/kawamoto/.emacs.d/elpa/use-package-20210207.1926/use-package 
hides 
/Applications/Emacs.app/Contents/Resources/lisp/use-package/use-package
/Users/kawamoto/.emacs.d/elpa/use-package-20210207.1926/use-package-bind-key 
hides 
/Applications/Emacs.app/Contents/Resources/lisp/use-package/use-package-bind-key
/Users/kawamoto/.emacs.d/elpa/bind-key-20210210.1609/bind-key hides 
/Applications/Emacs.app/Contents/Resources/lisp/use-package/bind-key
/Users/kawamoto/.emacs.d/elpa/use-package-20210207.1926/use-package-lint 
hides 
/Applications/Emacs.app/Contents/Resources/lisp/use-package/use-package-lint
/Users/kawamoto/.emacs.d/elpa/csharp-mode-20210826.421/csharp-mode hides 
/Applications/Emacs.app/Contents/Resources/lisp/progmodes/csharp-mode
/Users/kawamoto/.emacs.d/elpa/hierarchy-20190425.842/hierarchy hides 
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/hierarchy

Features:
(shadow sort mail-extr emacsbug message yank-media puny dired
dired-loaddefs rfc822 mml mml-sec 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 vc-dispatcher vc-svn
c++-ts-mode c-ts-mode c-ts-common time-date treesit-auto
use-package-ensure treesit cl-extra help-mode use-package-core
ag-autoloads tex-site easy-mmode dap-mode-autoloads
exec-path-from-shell-autoloads ggtags-autoloads gnuplot-autoloads
helm-easymenu helpful-autoloads rx lsp-docker-autoloads
lsp-treemacs-autoloads lsp-mode-autoloads
markdown-preview-mode-autoloads multi-term-autoloads leaf-autoloads
search-web-autoloads selected-autoloads tab-group-autoloads
treemacs-all-the-icons-autoloads treemacs-evil-autoloads evil-autoloads
goto-chg-autoloads treemacs-icons-dired-autoloads
treemacs-magit-autoloads treemacs-persp-autoloads persp-mode-autoloads
treemacs-projectile-autoloads treemacs-tab-bar-autoloads
treemacs-autoloads treesit-auto-autoloads advice uuidgen-autoloads
web-server-autoloads websocket-autoloads which-key-autoloads
yaml-autoloads yasnippet-snippets-autoloads yasnippet-autoloads info
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
password-cache json subr-x map byte-opt gv bytecomp byte-compile
url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/ns-win ns-win ucs-normalize mule-util term/common-win 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 kqueue cocoa ns multi-tty
make-network-process emacs)

Memory information:
((conses 16 97390 6196)
  (symbols 48 11132 0)
  (strings 32 36648 3094)
  (string-bytes 1 1326147)
  (vectors 16 17409)
  (vector-slots 8 243151 10031)
  (floats 8 35 24)
  (intervals 56 294 0)
  (buffers 984 12))