From unknown Sat Jun 21 03:16:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78814: 31.0.50; problems setting custom c++-ts-mode indent style Resent-From: "Jacek =?UTF-8?Q?=C5=9Awierk?=" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Jun 2025 10:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 78814 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 78814@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.175015448811155 (code B ref -1); Tue, 17 Jun 2025 10:02:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Jun 2025 10:01:28 +0000 Received: from localhost ([127.0.0.1]:54138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uRT8A-0002tk-CB for submit@debbugs.gnu.org; Tue, 17 Jun 2025 06:01:27 -0400 Received: from lists.gnu.org ([2001:470:142::17]:33926) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uROhj-0002Qq-Om for submit@debbugs.gnu.org; Tue, 17 Jun 2025 01:17:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uROhd-0005eJ-SB for bug-gnu-emacs@gnu.org; Tue, 17 Jun 2025 01:17:45 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uROhb-0004IJ-Tb for bug-gnu-emacs@gnu.org; Tue, 17 Jun 2025 01:17:45 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-ad89ee255easo971734966b.3 for ; Mon, 16 Jun 2025 22:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750137461; x=1750742261; darn=gnu.org; h=content-transfer-encoding:content-language:subject:to:user-agent :mime-version:date:message-id:from:from:to:cc:subject:date :message-id:reply-to; bh=W/iNMofilA1T8kLUOPtb3GMqnKYoF7PMpUvs3/E8soc=; b=Put+Di6F1kUM2QEEKMSLhVLsQfz4tWRIhvMrWrwdVuA3o1j/PCPBAKiVw4pBD7RPeB jfSMUuq6ZalweY3ucpvUSCEcRqCjyN4UZpYoJoturyJJf6f6vi5hmqgg0eRDoTJ0a4Dr p5psF2zwm/ett4nNUpOE1nTR2Gkf54Vxi26ONxPgzP+votIi0qx4VGUxtk+ZZbfni7IS taRU5u3TzHFpG0V51WfIvRXbN3SslsvxClzdc6K/8XxRdmu55OtcZicqfWOYGujJdkGr XAehu3yKp+VLZrUcYoAgzvdJvAgfLNHgNDXTG8AxQHwqA2mh6BHI22CnWdOcjGL6/BCh YOkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750137461; x=1750742261; h=content-transfer-encoding:content-language:subject:to:user-agent :mime-version:date:message-id:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W/iNMofilA1T8kLUOPtb3GMqnKYoF7PMpUvs3/E8soc=; b=NzZV0o/WKXVXarM/t7Oc2qWVBNerK69kqyImDtKiepbtyoITTpQKQrqZ/dwsWJG3mG MM4Bi2/Vi09zEn4FR75kZ4u2c0TGYs/I7AUzTK+8VDAPANuyHdJQx+yHE+Z+rcPIA/px lJP4gHKl276STTpBmnMubfV7be2vHr6eLbgSFb3pLRiTGppc1ELRjv3tOknu6XlnImtY KwWzFeAEyfoVpUF6MfgTJtHpXnjKCuG9KjKW0dovRbbJpj4kSrHB6K162BXccHsAsW9H gSdUTyoFbIhT6o1Knz0x2erYNgLzNQv4U9A7RTWcjoeCqLCg466c6SxVce/2t+tTOaWt paMA== X-Gm-Message-State: AOJu0YxinhMYfzvezvSJdJS4zTGZ0AZxcG0awjtOVsGLK2bgiIGsLRnW oHs2VoCwdEtzN9PC2BwfsQryuqwwg2f42nM26//YdwRef0kRmD7Yy63FpLOSzEHHeCA= X-Gm-Gg: ASbGnctnAWdE+xOwKz2tEtM5ZAPz2mmtpjvAPfz86BIEHiTiOkhHuEf5gOlHSiBG2HE rX8sXOdHy/JBZcE01WjLOQK/tDr+x6J4Lt+teY9ecNaPdPG4zbPFqsoAiGNSJ2mhq7esM3u+cej VigucDB1I+KbuCj8Rz59LZ0SL5Az4phN+eg1FvgKk6KxB5kgC+ixCYgUAVDJyvdaizdkPKDC6JQ 9BEq4rRPjlNZI1kqSKfDK+gRfU3L8fN6yFcPoVuzfA1KuST3fyKPPEcV4XC7hHO3LaVHEtpdtqm q2FHfNuosh0iiZWhZQaOPiGzV5Aifx4R/qA0SjK76GC6WhdP1f3XTLeG8VeVhNzSFtp4+ltUag= = X-Google-Smtp-Source: AGHT+IH+El9oRRMw1yVxd5pxyz4U8fu49KoWGvbpEd7j1WAPPL0VpTfK9F5SDn1AYqZMpU9XkE+WzA== X-Received: by 2002:a17:907:3f08:b0:ade:7a73:8db0 with SMTP id a640c23a62f3a-adfad682fc0mr1246705766b.54.1750137460784; Mon, 16 Jun 2025 22:17:40 -0700 (PDT) Received: from [192.168.1.5] ([89.67.5.94]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-60900cdd4f1sm4363832a12.2.2025.06.16.22.17.40 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Jun 2025 22:17:40 -0700 (PDT) From: "Jacek =?UTF-8?Q?=C5=9Awierk?=" X-Google-Original-From: Jacek =?UTF-8?Q?=C5=9Awierk?= Message-ID: Date: Tue, 17 Jun 2025 07:17:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=jacekswierk@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Mailman-Approved-At: Tue, 17 Jun 2025 06:01:24 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) I encountered two separate issues while configuring a non-default indentation style in c++-ts-mode (although one of them also applies to c-ts-mode). When invoking C-c . to set a style, c-ts-mode-set-style incorrectly sets treesit-simple-indent-rules to nil, preventing proper indentation. I believe the issue stems from a typo in the c-ts-mode-set-style function. Specifically, when the mode is c++-ts-mode, the function passes the symbol 'c++ to c-ts-mode--simple-indent-rules, but the function expects the symbol 'cpp instead. To reproduce: M-x c++-ts-mode C-c . and pick any style C-h v treesit-simple-indent-rules should show nil and indentation does not work correctly As for the second issue, in definitions of both c-ts-mode and c++-ts-mode, treesit-simple-indent-rules is derived from the return value of c-ts-mode--simple-indent-rules (lines 1486 and 1559). However, if the user customizes the indentation style by setting c-ts-mode-indent-style to a function, the current implementation breaks. The c-ts-mode--simple-indent-rules function expects one of the four predefined styles, but when c-ts-mode-indent-style is a custom function, it does not handle this correctly. To reproduce: Set c-ts-mode-indent-style to some custom function M-x c++-ts-mode C-h v treesit-simple-indent-rules should show ((cpp)) and indentation does not work correctly In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.49, cairo version 1.18.4) of 2025-06-13 built on arch Repository revision: bec823b107ef7d3b51b8e430ccab82c81bd63d24 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12401006 System Description: Arch Linux Configured using: 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games --with-modules --without-m17n-flt --without-gconf --with-native-compilation=yes --with-xinput2 --with-x-toolkit=gtk3 --without-xaw3d --with-sound=no --with-tree-sitter --without-gpm --without-compress-install '--program-transform-name=s/\([ec]tags\)/\1.emacs/' 'CFLAGS=-march=native -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' 'LDFLAGS=-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -fuse-ld=mold'' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINERAMA XINPUT2 XPM XRANDR GTK3 ZLIB Important settings: value of $LC_MESSAGES: en_US.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: im=fcit locale-coding-system: utf-8-unix Major mode: C++// Minor modes in effect: tooltip-mode: t global-eldoc-mode: t 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 minibuffer-regexp-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: None found. Features: (shadow sort mail-extr compile comint ansi-osc ansi-color ring emacsbug lisp-mnt message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache 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 time-date subr-x cl-extra cl-print thingatpt help-fns byte-opt gv radix-tree help-mode comp-run bytecomp byte-compile comp-common rx cl-seq c++-ts-mode c-ts-mode c-ts-common treesit cl-loaddefs cl-lib 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 system-font-setting font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar make-network-process tty-child-frames native-compile emacs) Memory information: ((conses 16 86721 11062) (symbols 48 7857 0) (strings 32 23041 2379) (string-bytes 1 683662) (vectors 16 13204) (vector-slots 8 177281 10463) (floats 8 82 1) (intervals 56 335 0) (buffers 1064 12)) From unknown Sat Jun 21 03:16:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78814: 31.0.50; problems setting custom c++-ts-mode indent style Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Jun 2025 09:19:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78814 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Jacek =?UTF-8?Q?=C5=9Awierk?= Cc: 78814@debbugs.gnu.org Received: via spool by 78814-submit@debbugs.gnu.org id=B78814.175049750818928 (code B ref 78814); Sat, 21 Jun 2025 09:19:03 +0000 Received: (at 78814) by debbugs.gnu.org; 21 Jun 2025 09:18:28 +0000 Received: from localhost ([127.0.0.1]:33756 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uSuMk-0004uv-IL for submit@debbugs.gnu.org; Sat, 21 Jun 2025 05:18:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57506) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uSuMh-0004tU-GX for 78814@debbugs.gnu.org; Sat, 21 Jun 2025 05:18:24 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSuMc-0001SD-4i; Sat, 21 Jun 2025 05:18:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=VoWgL9TVFZzpZLvBj6uW/AabKxB4a5ajdUKACcnqZ4A=; b=DfLas+AAIlo0ib+CNghb x3WXaqWzE6DCzQhNOy+TFZpHCCKTxV7Rv/uE4oDMST5lVbwpdlmaXazqbO5n40krP7ZBdCW6ZEReU HO0MOybD7fWY3UhhMyssNUQ781As1ihQuhhq1COe1HD6ByeXNJXjUvfRokhIuFYEUvYIrmP3k4LWA ze4nLpMNn2in8eeAJLlfvY4MBZ4mwu1enE811k19pmiXV0OwBzOkCJ1naNKdDFlXsCQ+VtG44nhTW d3bZm0XgdKwtdgql1RZiTIpYkJkRkFmJzxk+WT5ZrsLTOoexCxEA/k1Q/KwSlCYj1cUXw5axk2Y4q RtMFug3JrQzCQA==; Date: Sat, 21 Jun 2025 12:18:14 +0300 Message-Id: <864iw9jvvt.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (jacekswierk@gmail.com) References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: "Jacek Świerk" > Date: Tue, 17 Jun 2025 07:17:39 +0200 > > I encountered two separate issues while configuring a non-default > indentation style in c++-ts-mode (although one of them also applies to > c-ts-mode). > > When invoking C-c . to set a style, c-ts-mode-set-style incorrectly sets > treesit-simple-indent-rules to nil, preventing proper indentation. > > I believe the issue stems from a typo in the c-ts-mode-set-style > function. Specifically, when the mode is c++-ts-mode, the function > passes the symbol 'c++ to c-ts-mode--simple-indent-rules, but the > function expects the symbol 'cpp instead. > > To reproduce: > > M-x c++-ts-mode > C-c . and pick any style > C-h v treesit-simple-indent-rules should show nil and indentation does > not work correctly Thanks, I fixed this typo on the master branch. > As for the second issue, in definitions of both c-ts-mode and > c++-ts-mode, treesit-simple-indent-rules is derived from the return > value of c-ts-mode--simple-indent-rules (lines 1486 and 1559). However, > if the user customizes the indentation style by setting > c-ts-mode-indent-style to a function, the current implementation breaks. > The c-ts-mode--simple-indent-rules function expects one of the four > predefined styles, but when c-ts-mode-indent-style is a custom function, > it does not handle this correctly. > > To reproduce: > > Set c-ts-mode-indent-style to some custom function > M-x c++-ts-mode > C-h v treesit-simple-indent-rules should show ((cpp)) and indentation > does not work correctly Thanks, but please show a more detailed recipe, with a specific custom function, so I could more easily investigate this issue. Alternatively provide more details about what goes wrong in the code in this case, in particular of this sentence: > The c-ts-mode--simple-indent-rules function expects one of the four > predefined styles, but when c-ts-mode-indent-style is a custom function, > it does not handle this correctly. I don't understand which call to c-ts-mode--simple-indent-rules is at fault here, and what does "does not handle this correctly" mean.