GNU bug report logs - #75442
31.0.50; c-ts-mode indentation problem

Previous Next

Package: emacs;

Reported by: Uygar KÖSEER <uygarkoseer <at> gmail.com>

Date: Wed, 8 Jan 2025 17:56:01 UTC

Severity: normal

Found in version 31.0.50

Done: Yuan Fu <casouri <at> gmail.com>

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 75442 in the body.
You can then email your comments to 75442 AT debbugs.gnu.org in the normal way.

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#75442; Package emacs. (Wed, 08 Jan 2025 17:56:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Uygar KÖSEER <uygarkoseer <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 08 Jan 2025 17:56:01 GMT) Full text and rfc822 format available.

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

From: Uygar KÖSEER <uygarkoseer <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; c-ts-mode indentation problem
Date: Wed, 8 Jan 2025 20:28:11 +0300
[Message part 1 (text/plain, inline)]
Hi,

I started to use c-ts-mode (tree-sitter) and I think there is a little
indentation problem when typedef declaration is used.

Wrong indentation case:

typedef struct Point
        {
            int x;
            int y;
        } Point;

I think this happens because it aligns it with the struct keyword.

Working case:
typedef struct Point Point;
struct Point
{
    int x;
    int y;
} Point;

This case works without problem because the struct keyword is at the
beginning of the line.

Both of the cases are matched with this part in c-ts-mode.el:
((parent-is ,(rx (or "function_definition"
                                "struct_specifier"
                                "enum_specifier"
                                "function_declarator"
                                "template_declaration")))
            parent 0)

I also tried to change this behaviour by adding new rules to my
c-ts-mode configuration but it always matches with the default
configuration first. I do not know if there is any way to change this
behaviour without re-defining all the default configuration.


In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.33, cairo version 1.16.0) of 2025-01-08 built on DESKTOP-NF56V2Q
System Description: Ubuntu 22.04.3 LTS

Configured using:
 'configure --with-native-compilation --with-pgtk --with-x-toolkit=lucid
 --with-tree-sitter --with-mailutils'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER XIM GTK3 ZLIB

Important settings:
  value of $LANG: C.UTF-8
  locale-coding-system: utf-8-unix

Major mode: C/*

Minor modes in effect:
  highlight-numbers-mode: t
  rainbow-delimiters-mode: t
  fancy-dabbrev-mode: t
  marginalia-mode: t
  savehist-mode: t
  projectile-mode: t
  vertico-mode: t
  gcmh-mode: t
  recentf-mode: t
  repeat-mode: t
  global-auto-revert-mode: t
  global-so-long-mode: t
  global-hl-line-mode: t
  electric-pair-mode: t
  override-global-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
  window-divider-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  global-visual-line-mode: t
  visual-line-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:
/home/nukoseer/.emacs.d/elpa/modus-themes-20241228.1050/theme-loaddefs
hides /usr/local/share/emacs/31.0.50/lisp/theme-loaddefs

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 mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils mule-util bug-reference cursor-sensor comp-run
comp-common highlight-numbers parent-mode rainbow-delimiters
fancy-dabbrev popup dabbrev c++-ts-mode c-ts-mode c-ts-common treesit
which-key marginalia orderless savehist projectile project lisp-mnt
thingatpt rg vc vc-dispatcher rg-info-hack rg-menu transient pcase
rg-ibuffer rg-result wgrep-rg wgrep rg-history rg-header ibuf-ext
ibuffer ibuffer-loaddefs vertico compat tramp trampver tramp-integration
files-x tramp-message tramp-compat shell pcomplete parse-time iso8601
time-date format-spec tramp-loaddefs smartscan gcmh modus-vivendi-theme
modus-themes cus-edit pp grep compile text-property-search comint
ansi-osc ansi-color ring cus-load recentf tree-widget wid-edit repeat
autorevert filenotify display-line-numbers so-long hl-line elec-pair
narrow-indirect make-mark-visible edmacro kmacro advice rx cl-extra
help-mode finder-inf use-package use-package-ensure use-package-delight
use-package-diminish use-package-bind-key bind-key easy-mmode
use-package-core avy-autoloads buffer-move-autoloads
consult-dir-autoloads dumb-jump-autoloads dash-autoloads
embark-consult-autoloads consult-autoloads embark-autoloads
fancy-dabbrev-autoloads gcmh-autoloads highlight-numbers-autoloads
marginalia-autoloads modus-themes-autoloads multiple-cursors-autoloads
orderless-autoloads parent-mode-autoloads popup-autoloads
projectile-autoloads rainbow-delimiters-autoloads info rg-autoloads
s-autoloads smartscan-autoloads vertico-autoloads wgrep-autoloads
package browse-url xdg 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 icons
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/pgtk-win pgtk-win term/common-win touch-screen pgtk-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
dynamic-setting system-font-setting font-render-setting cairo gtk pgtk
lcms2 multi-tty move-toolbar make-network-process tty-child-frames
native-compile emacs)

Memory information:
((conses 16 485596 224491) (symbols 48 26240 173)
 (strings 32 135066 15749) (string-bytes 1 3787317) (vectors 16 36037)
 (vector-slots 8 439371 76445) (floats 8 134 924)
 (intervals 56 827 240) (buffers 992 13))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75442; Package emacs. (Sat, 11 Jan 2025 01:21:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Uygar KÖSEER <uygarkoseer <at> gmail.com>, 
 75442 <at> debbugs.gnu.org
Cc: Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#75442: 31.0.50; c-ts-mode indentation problem
Date: Sat, 11 Jan 2025 01:20:48 +0000
Uygar KÖSEER <uygarkoseer <at> gmail.com> writes:

> Hi,
>
> I started to use c-ts-mode (tree-sitter) and I think there is a little
> indentation problem when typedef declaration is used.
>
> Wrong indentation case:
>
> typedef struct Point
>         {
>             int x;
>             int y;
>         } Point;
>
> I think this happens because it aligns it with the struct keyword.
>
> Working case:
> typedef struct Point Point;
> struct Point
> {
>     int x;
>     int y;
> } Point;
>
> This case works without problem because the struct keyword is at the
> beginning of the line.
>
> Both of the cases are matched with this part in c-ts-mode.el:
> ((parent-is ,(rx (or "function_definition"
>                                 "struct_specifier"
>                                 "enum_specifier"
>                                 "function_declarator"
>                                 "template_declaration")))
>             parent 0)
>
> I also tried to change this behaviour by adding new rules to my
> c-ts-mode configuration but it always matches with the default
> configuration first. I do not know if there is any way to change this
> behaviour without re-defining all the default configuration.

Theodor, any comments here?




Reply sent to Yuan Fu <casouri <at> gmail.com>:
You have taken responsibility. (Mon, 13 Jan 2025 06:26:02 GMT) Full text and rfc822 format available.

Notification sent to Uygar KÖSEER <uygarkoseer <at> gmail.com>:
bug acknowledged by developer. (Mon, 13 Jan 2025 06:26:02 GMT) Full text and rfc822 format available.

Message #13 received at 75442-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Theodor Thornhill <theo <at> thornhill.no>,
 Uygar KÖSEER <uygarkoseer <at> gmail.com>,
 75442-done <at> debbugs.gnu.org
Subject: Re: bug#75442: 31.0.50; c-ts-mode indentation problem
Date: Sun, 12 Jan 2025 22:25:31 -0800

> On Jan 10, 2025, at 5:20 PM, Stefan Kangas <stefankangas <at> gmail.com> wrote:
> 
> Uygar KÖSEER <uygarkoseer <at> gmail.com> writes:
> 
>> Hi,
>> 
>> I started to use c-ts-mode (tree-sitter) and I think there is a little
>> indentation problem when typedef declaration is used.
>> 
>> Wrong indentation case:
>> 
>> typedef struct Point
>>        {
>>            int x;
>>            int y;
>>        } Point;
>> 
>> I think this happens because it aligns it with the struct keyword.
>> 
>> Working case:
>> typedef struct Point Point;
>> struct Point
>> {
>>    int x;
>>    int y;
>> } Point;
>> 
>> This case works without problem because the struct keyword is at the
>> beginning of the line.
>> 
>> Both of the cases are matched with this part in c-ts-mode.el:
>> ((parent-is ,(rx (or "function_definition"
>>                                "struct_specifier"
>>                                "enum_specifier"
>>                                "function_declarator"
>>                                "template_declaration")))
>>            parent 0)
>> 
>> I also tried to change this behaviour by adding new rules to my
>> c-ts-mode configuration but it always matches with the default
>> configuration first. I do not know if there is any way to change this
>> behaviour without re-defining all the default configuration.
> 
> Theodor, any comments here?

This is caused by some recent changes I made. I pushed a fix to master.

Yuan



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 10 Feb 2025 12:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 127 days ago.

Previous Next


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