unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#75442: 31.0.50; c-ts-mode indentation problem
@ 2025-01-08 17:28 Uygar KÖSEER
  2025-01-11  1:20 ` Stefan Kangas
  0 siblings, 1 reply; 3+ messages in thread
From: Uygar KÖSEER @ 2025-01-08 17:28 UTC (permalink / raw)
  To: 75442

[-- Attachment #1: Type: text/plain, Size: 6205 bytes --]

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))

[-- Attachment #2: Type: text/html, Size: 6879 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#75442: 31.0.50; c-ts-mode indentation problem
  2025-01-08 17:28 bug#75442: 31.0.50; c-ts-mode indentation problem Uygar KÖSEER
@ 2025-01-11  1:20 ` Stefan Kangas
  2025-01-13  6:25   ` Yuan Fu
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Kangas @ 2025-01-11  1:20 UTC (permalink / raw)
  To: Uygar KÖSEER, 75442; +Cc: Theodor Thornhill

Uygar KÖSEER <uygarkoseer@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?





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#75442: 31.0.50; c-ts-mode indentation problem
  2025-01-11  1:20 ` Stefan Kangas
@ 2025-01-13  6:25   ` Yuan Fu
  0 siblings, 0 replies; 3+ messages in thread
From: Yuan Fu @ 2025-01-13  6:25 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Theodor Thornhill, Uygar KÖSEER, 75442-done



> On Jan 10, 2025, at 5:20 PM, Stefan Kangas <stefankangas@gmail.com> wrote:
> 
> Uygar KÖSEER <uygarkoseer@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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-13  6:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-08 17:28 bug#75442: 31.0.50; c-ts-mode indentation problem Uygar KÖSEER
2025-01-11  1:20 ` Stefan Kangas
2025-01-13  6:25   ` Yuan Fu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).