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

Previous Next

Package: emacs;

Reported by: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) <kawamoto.takuji <at> gmail.com>

Date: Sun, 26 May 2024 07:38:01 UTC

Severity: normal

Found in version 29.3

To reply to this bug, email your comments to 71205 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#71205; Package emacs. (Sun, 26 May 2024 07:38:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) <kawamoto.takuji <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 26 May 2024 07:38:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.3; Automatic indentation of c-ts-mode doesn't work well for me.
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))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71205; Package emacs. (Sun, 26 May 2024 08:13:02 GMT) Full text and rfc822 format available.

Message #8 received at 71205 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: 川本 琢二(Dr.Sc.KAWAMOTO, Takuji) <kawamoto.takuji <at> gmail.com>,
 Yuan Fu <casouri <at> gmail.com>
Cc: 71205 <at> debbugs.gnu.org
Subject: Re: bug#71205: 29.3;
 Automatic indentation of c-ts-mode doesn't work well for me.
Date: Sun, 26 May 2024 11:12:23 +0300
> Date: Sun, 26 May 2024 13:32:37 +0900
> From: 川本 琢二
>  (Dr.Sc.KAWAMOTO, Takuji) <kawamoto.takuji <at> gmail.com>
> 
> 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.

I think this is because the above source code fails to parse.  If you
add a closing brace after the "do" line, and then repeat your recipe,
the cursor goes to column 3.

Yuan, can you please look into this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71205; Package emacs. (Thu, 06 Jun 2024 06:41:02 GMT) Full text and rfc822 format available.

Message #11 received at 71205 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: "川本 琢二(Dr.Sc.KAWAMOTO, Takuji)"
 <kawamoto.takuji <at> gmail.com>, 71205 <at> debbugs.gnu.org
Subject: Re: bug#71205: 29.3; Automatic indentation of c-ts-mode doesn't work
 well for me.
Date: Wed, 5 Jun 2024 22:25:58 -0700

> On May 26, 2024, at 1:12 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> Date: Sun, 26 May 2024 13:32:37 +0900
>> From: 川本 琢二
>> (Dr.Sc.KAWAMOTO, Takuji) <kawamoto.takuji <at> gmail.com>
>> 
>> 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.
> 
> I think this is because the above source code fails to parse.  If you
> add a closing brace after the "do" line, and then repeat your recipe,
> the cursor goes to column 3.
> 
> Yuan, can you please look into this?

Thanks for your detailed report, Kawamoto san. Yes, this is due to the source code not being complete (missing closing brackets). For the moment, I suggest turning on electric-pair-mode which automatically adds closing brackets.

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71205; Package emacs. (Fri, 07 Jun 2024 03:51:04 GMT) Full text and rfc822 format available.

Message #14 received at 71205 <at> debbugs.gnu.org (full text, mbox):

From: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
To: Yuan Fu <casouri <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 71205 <at> debbugs.gnu.org
Subject: Re: bug#71205: 29.3; Automatic indentation of c-ts-mode doesn't work
 well for me.
Date: Fri, 7 Jun 2024 00:53:02 +0900
Thanks for your answer, Mr Yuan.
This answer solved the original problem.

Instead, I think a new problem has been revealed.
What we should expect is for the cursor to move to column 5, because 
that's gnu style.
But it actually moves to column 3.

Thanks all.

On 2024/06/06 14:25, Yuan Fu wrote:
>
>> On May 26, 2024, at 1:12 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>
>>> Date: Sun, 26 May 2024 13:32:37 +0900
>>> From: 川本 琢二
>>> (Dr.Sc.KAWAMOTO, Takuji) <kawamoto.takuji <at> gmail.com>
>>>
>>> 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.
>> I think this is because the above source code fails to parse.  If you
>> add a closing brace after the "do" line, and then repeat your recipe,
>> the cursor goes to column 3.
>>
>> Yuan, can you please look into this?
> Thanks for your detailed report, Kawamoto san. Yes, this is due to the source code not being complete (missing closing brackets). For the moment, I suggest turning on electric-pair-mode which automatically adds closing brackets.
>
> Yuan





This bug report was last modified 132 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.