From unknown Fri Aug 15 18:06:50 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 Fri Aug 15 18:06:50 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. From unknown Fri Aug 15 18:06:50 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 14:45:01 +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.175051706220987 (code B ref 78814); Sat, 21 Jun 2025 14:45:01 +0000 Received: (at 78814) by debbugs.gnu.org; 21 Jun 2025 14:44:22 +0000 Received: from localhost ([127.0.0.1]:40963 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uSzSA-0005SP-0i for submit@debbugs.gnu.org; Sat, 21 Jun 2025 10:44:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57940) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uSzS6-0005Rw-7m for 78814@debbugs.gnu.org; Sat, 21 Jun 2025 10:44:19 -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 1uSzS0-00087F-T1; Sat, 21 Jun 2025 10:44:12 -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=fsDrH70EJCFmLMr8lanWkapVXNqwZLCVBnWs/DXiy5o=; b=QcOKUJmIvHFHP+h3reT2 jlhJ6lSYsL/INBTZ4IgGZigPaZawb2u9zbBMMiAk+RumpDEsOpb1RUcDYY6xUz989ffMruOnfcZBH ujvO8E7uozxruYBAZBa4i9RpfFPp0V5N0mK+cmfrF3VLLBaq/84JujTGPZKBC2JjEMcqCXe6/rA4T UUjN/UNP0GNvtcaOVZB4bpGNjzDndCBsRjNGJVfpHYuv4MMgusGln2bYs4HF7vxoWuOK95JLhuWzX ZH1rGuv6+kcvhGHH838plrfc/Qae8FLheOLj2f0ZoAMYkSX0MCSpIwMr6ZrrbC4t3OpPoqglXvigi IOQFdCI6nCQyzA==; Date: Sat, 21 Jun 2025 17:44:10 +0300 Message-Id: <86plexi285.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Jacek =?UTF-8?Q?=C5=9Awierk?= on Sat, 21 Jun 2025 16:29:19 +0200) References: <864iw9jvvt.fsf@gnu.org> 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 (---) [Please use Reply All to reply, to keep the bug tracker CC'ed.] > From: Jacek Świerk > Date: Sat, 21 Jun 2025 16:29:19 +0200 > > Here's more detailed reproduction recipe: > > 1. Define a custom indentation style for C++: > (defun my--c++-ts-mode-indent-style () > "Use BSD style but don't indent inside namespaces." > `((cpp > ((n-p-gp nil nil "namespace_definition") grand-parent 0) > ,@(cdr (car (c-ts-mode--simple-indent-rules 'cpp 'bsd)))))) > > 2. Set the custom style as default: > (setopt c-ts-mode-indent-style 'my--c++-ts-mode-indent-style) > > 3. Enable C++ treesit mode: > (c++-ts-mode) > > 4. Verify `treesit-simple-indent-rules` - it shows only `((cpp))` instead of the expected rules. > > This happens because c-ts-mode--simple-indent-rules, which is called while > changing major mode (line 1563) to c++-ts-mode, has pcase only for 4 styles > (gnu, k&r, linux and bsd), meaning it doesn't handle the situation when > c-ts-mode-indent-style is set to some custom function. I can work around it by > calling (setopt c-ts-mode-indent-style 'my--c++-ts-mode-indent-style) after > switching to c++-ts-mode with a hook but is this the expected flow? Thanks. Does the patch below fix the problem? diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 0df9fe3..5155193 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -1487,8 +1487,10 @@ c-ts-mode (setq-local comment-end " */") ;; Indent. (setq-local treesit-simple-indent-rules - (c-ts-mode--simple-indent-rules - 'c c-ts-mode-indent-style)) + (if (functionp c-ts-mode-indent-style) + (funcall c-ts-mode-indent-style) + (c-ts-mode--simple-indent-rules + 'c c-ts-mode-indent-style))) ;; (setq-local treesit-simple-indent-rules ;; `((c . ,(alist-get 'gnu (c-ts-mode--indent-styles 'c))))) ;; Font-lock. @@ -1560,8 +1562,10 @@ c++-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules - (c-ts-mode--simple-indent-rules - 'cpp c-ts-mode-indent-style)) + (if (functionp c-ts-mode-indent-style) + (funcall c-ts-mode-indent-style) + (c-ts-mode--simple-indent-rules + 'cpp c-ts-mode-indent-style))) ;; Font-lock. (setq-local treesit-font-lock-settings From unknown Fri Aug 15 18:06:50 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: Sun, 22 Jun 2025 01:16:01 +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: Eli Zaretskii Cc: 78814@debbugs.gnu.org Received: via spool by 78814-submit@debbugs.gnu.org id=B78814.17505549419699 (code B ref 78814); Sun, 22 Jun 2025 01:16:01 +0000 Received: (at 78814) by debbugs.gnu.org; 22 Jun 2025 01:15:41 +0000 Received: from localhost ([127.0.0.1]:44802 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uT9J3-0002Vj-EK for submit@debbugs.gnu.org; Sat, 21 Jun 2025 21:15:40 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]:45205) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uT4qy-0004iR-78 for 78814@debbugs.gnu.org; Sat, 21 Jun 2025 16:30:21 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-553b165c80cso2893324e87.2 for <78814@debbugs.gnu.org>; Sat, 21 Jun 2025 13:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750537814; x=1751142614; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SQvgACA6uU14bD0gpqVLtnkHDnwCL5PbXLdkqd4ejL8=; b=GvMsXtexUn92SXB/7AUh7KP7tdb7tDw9xN/nrtpa54iD6sasHYDrYEBLAGaOjUbCTl 9+bwYaez/l0SwYRrjlvAOEk+DKw7VsrygzGLl4uCJUkVqcA5+dUcszzOxFz3NztS5vGA oySCrv0nYpPpyjt5VQbGAGOy1QxT7laQECEOC5dCPKqx+/WoVJHgZ6P45CObCWG1ghzX c7SopOi9kkVFmLdRCecwt5GYDXTOUlgelJrfsfNyLtY/869N9IzJ2FJjHLkDX3dzXHVT XJbno9WNGuYwaK8ELZZsCvgrwWgFsG5C4GZegLobP11ky/FciORuMpOAZ2QVrDhfnHDl cIow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750537814; x=1751142614; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SQvgACA6uU14bD0gpqVLtnkHDnwCL5PbXLdkqd4ejL8=; b=nPOnaN+wfANeAzL913Yr/r6AR7Ec7AviXXp7M5q0UHQYxusv3M+7Iioqzwf2IM+ehV 7ipP3wXZYrbQND8SABaoSyxF1Q/65PkSGjafjMLqWIynvuFwzfT5BJcoKpyHy2Qs51+1 afuSxi5X3JjKgjbA038uQu4CnKvpwsTDDoafzSu4cDJh6HPfyKi7ZblgGKF9q1xT3pnS yrGHGpJDbgcNeSyOmN18VbjFji16JXzNXuB7IUxEsrivIuaqFIyvqe9NKbtE9VM5au5u wIPfb4o49/7LgtkENzgIyjTuuoe5pJkUtRk7732eRUhgRQ0sbRj1mvb1TFDyhdYhvl8R 6tfg== X-Gm-Message-State: AOJu0Yyi+g9E0FJriKbyL2AN4hm0bzAZEpG8GwswF8yHaTM2nFLV+upz Sbj5h8WP0PgeuQawsz56wI7+JmSJYTKLyfNahfD9bMMLBEQZ3RjouKNThyABrZmPG2uWqe9HzpP aiHOXa8Xmpg61EF+AmNHqfu0333bseLsvhv1F X-Gm-Gg: ASbGncuKOlU/PwJa+bHhxH0Ov5NZIiIWQI2ddPRE0qKU0PH2PftTki+CmwYSr97D+t8 fjkqTBTDJywNn0CP3SseoKWvChq9g5DK3f6cIIKuJzVEoYBmQi4lSep9ogmZiNxRe10ucaeMFJw nNSZflO+NXjTuwwa94bR58yJh6g72yf1sOI+Qqv1HzTw3ycwij1Q== X-Google-Smtp-Source: AGHT+IHfl68CVxiwQLDKDfgNytIvsYCqFxfMKw3qSsRIDKQxL1XnqDxHpUEmB9/5SLb2DN58xbyWfRIUVcEMxeSkoQo= X-Received: by 2002:a05:6512:b0a:b0:553:522f:61c9 with SMTP id 2adb3069b0e04-553e3b9a909mr2154893e87.1.1750537813435; Sat, 21 Jun 2025 13:30:13 -0700 (PDT) MIME-Version: 1.0 References: <864iw9jvvt.fsf@gnu.org> <86plexi285.fsf@gnu.org> In-Reply-To: <86plexi285.fsf@gnu.org> From: Jacek =?UTF-8?Q?=C5=9Awierk?= Date: Sat, 21 Jun 2025 22:30:02 +0200 X-Gm-Features: AX0GCFuQG71DN1DNei_fpwlcIWFDCTEybUWWvQkaHFrPTM7VeDi76IZfpiGvyuo Message-ID: Content-Type: multipart/alternative; boundary="000000000000892b6c06381ad8f8" X-Spam-Score: 0.0 (/) X-Mailman-Approved-At: Sat, 21 Jun 2025 21:15:34 -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: -1.0 (-) --000000000000892b6c06381ad8f8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yes, works like charm. sob., 21 cze 2025 o 16:44 Eli Zaretskii napisa=C5=82(a): > [Please use Reply All to reply, to keep the bug tracker CC'ed.] > > > From: Jacek =C5=9Awierk > > Date: Sat, 21 Jun 2025 16:29:19 +0200 > > > > Here's more detailed reproduction recipe: > > > > 1. Define a custom indentation style for C++: > > (defun my--c++-ts-mode-indent-style () > > "Use BSD style but don't indent inside namespaces." > > `((cpp > > ((n-p-gp nil nil "namespace_definition") grand-parent 0) > > ,@(cdr (car (c-ts-mode--simple-indent-rules 'cpp 'bsd)))))) > > > > 2. Set the custom style as default: > > (setopt c-ts-mode-indent-style 'my--c++-ts-mode-indent-style) > > > > 3. Enable C++ treesit mode: > > (c++-ts-mode) > > > > 4. Verify `treesit-simple-indent-rules` - it shows only `((cpp))` > instead of the expected rules. > > > > This happens because c-ts-mode--simple-indent-rules, which is called > while > > changing major mode (line 1563) to c++-ts-mode, has pcase only for 4 > styles > > (gnu, k&r, linux and bsd), meaning it doesn't handle the situation when > > c-ts-mode-indent-style is set to some custom function. I can work aroun= d > it by > > calling (setopt c-ts-mode-indent-style 'my--c++-ts-mode-indent-style) > after > > switching to c++-ts-mode with a hook but is this the expected flow? > > Thanks. Does the patch below fix the problem? > > diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el > index 0df9fe3..5155193 100644 > --- a/lisp/progmodes/c-ts-mode.el > +++ b/lisp/progmodes/c-ts-mode.el > @@ -1487,8 +1487,10 @@ c-ts-mode > (setq-local comment-end " */") > ;; Indent. > (setq-local treesit-simple-indent-rules > - (c-ts-mode--simple-indent-rules > - 'c c-ts-mode-indent-style)) > + (if (functionp c-ts-mode-indent-style) > + (funcall c-ts-mode-indent-style) > + (c-ts-mode--simple-indent-rules > + 'c c-ts-mode-indent-style))) > ;; (setq-local treesit-simple-indent-rules > ;; `((c . ,(alist-get 'gnu (c-ts-mode--indent-styles > 'c))))) > ;; Font-lock. > @@ -1560,8 +1562,10 @@ c++-ts-mode > > ;; Indent. > (setq-local treesit-simple-indent-rules > - (c-ts-mode--simple-indent-rules > - 'cpp c-ts-mode-indent-style)) > + (if (functionp c-ts-mode-indent-style) > + (funcall c-ts-mode-indent-style) > + (c-ts-mode--simple-indent-rules > + 'cpp c-ts-mode-indent-style))) > > ;; Font-lock. > (setq-local treesit-font-lock-settings > --000000000000892b6c06381ad8f8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Yes, works like charm.

sob., 21 = cze 2025 o 16:44=C2=A0Eli Zaretskii <eli= z@gnu.org> napisa=C5=82(a):
[Please use Reply All to reply, to keep the bug tracker = CC'ed.]

> From: Jacek =C5=9Awierk <jacekswierk@gmail.com>
> Date: Sat, 21 Jun 2025 16:29:19 +0200
>
> Here's more detailed reproduction recipe:
>
> 1. Define a custom indentation style for C++:
> (defun my--c++-ts-mode-indent-style ()
>=C2=A0 =C2=A0"Use BSD style but don't indent inside namespaces= ."
>=C2=A0 =C2=A0`((cpp
>=C2=A0 =C2=A0 =C2=A0 ((n-p-gp nil nil "namespace_definition")= grand-parent 0)
>=C2=A0 =C2=A0 =C2=A0 ,@(cdr (car (c-ts-mode--simple-indent-rules 'c= pp 'bsd))))))
>
> 2. Set the custom style as default:
> (setopt c-ts-mode-indent-style 'my--c++-ts-mode-indent-style)
>
> 3. Enable C++ treesit mode:
> (c++-ts-mode)
>
> 4. Verify `treesit-simple-indent-rules` - it shows only `((cpp))` inst= ead of the expected rules.
>
> This happens because c-ts-mode--simple-indent-rules, which is called w= hile
> changing major mode (line 1563) to c++-ts-mode, has pcase only for 4 s= tyles
> (gnu, k&r, linux and bsd), meaning it doesn't handle the situa= tion when
> c-ts-mode-indent-style is set to some custom function. I can work arou= nd it by
> calling (setopt c-ts-mode-indent-style 'my--c++-ts-mode-indent-sty= le) after
> switching to c++-ts-mode with a hook but is this the expected flow?
Thanks.=C2=A0 Does the patch below fix the problem?

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 0df9fe3..5155193 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -1487,8 +1487,10 @@ c-ts-mode
=C2=A0 =C2=A0 =C2=A0 =C2=A0(setq-local comment-end " */")
=C2=A0 =C2=A0 =C2=A0 =C2=A0;; Indent.
=C2=A0 =C2=A0 =C2=A0 =C2=A0(setq-local treesit-simple-indent-rules
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (c-ts-mode-= -simple-indent-rules
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'= c c-ts-mode-indent-style))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (functi= onp c-ts-mode-indent-style)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (funcall c-ts-mode-indent-style)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (c-t= s-mode--simple-indent-rules
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0'c c-ts-mode-indent-style)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0;; (setq-local treesit-simple-indent-rules
=C2=A0 =C2=A0 =C2=A0 =C2=A0;;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0`((c . ,(alist-get 'gnu (c-ts-mode--indent-styles 'c)))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0;; Font-lock.
@@ -1560,8 +1562,10 @@ c++-ts-mode

=C2=A0 =C2=A0 =C2=A0 =C2=A0;; Indent.
=C2=A0 =C2=A0 =C2=A0 =C2=A0(setq-local treesit-simple-indent-rules
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (c-ts-mode-= -simple-indent-rules
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'= cpp c-ts-mode-indent-style))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (functi= onp c-ts-mode-indent-style)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (funcall c-ts-mode-indent-style)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (c-t= s-mode--simple-indent-rules
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0'cpp c-ts-mode-indent-style)))

=C2=A0 =C2=A0 =C2=A0 =C2=A0;; Font-lock.
=C2=A0 =C2=A0 =C2=A0 =C2=A0(setq-local treesit-font-lock-settings
--000000000000892b6c06381ad8f8-- From unknown Fri Aug 15 18:06:50 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: "Jacek =?UTF-8?Q?=C5=9Awierk?=" Subject: bug#78814: closed (Re: bug#78814: 31.0.50; problems setting custom c++-ts-mode indent style) Message-ID: References: <86msa0gpfb.fsf@gnu.org> X-Gnu-PR-Message: they-closed 78814 X-Gnu-PR-Package: emacs Reply-To: 78814@debbugs.gnu.org Date: Sun, 22 Jun 2025 08:19:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1750580342-4721-1" This is a multi-part message in MIME format... ------------=_1750580342-4721-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #78814: 31.0.50; problems setting custom c++-ts-mode indent style which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 78814@debbugs.gnu.org. --=20 78814: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D78814 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1750580342-4721-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 78814-done) by debbugs.gnu.org; 22 Jun 2025 08:18:36 +0000 Received: from localhost ([127.0.0.1]:46464 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uTFuN-0001DW-QL for submit@debbugs.gnu.org; Sun, 22 Jun 2025 04:18:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34048) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uTFuK-0001DD-J1 for 78814-done@debbugs.gnu.org; Sun, 22 Jun 2025 04:18:34 -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 1uTFu7-0001Qi-2a; Sun, 22 Jun 2025 04:18:27 -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=wHIMdYgZrMs2BewyN3ANF+OuZ9JtTeWH8hKhQM92fOE=; b=oSiHc+sUpbGgYqH7M2yL 5eOuW0F62DLRr/w2A1L0qmI6HMEA5TP/uSqoxDPcyjJ4zg2t4n7dYf1nStqZQViEppJbJj5jaZ1qF Gf4REx9loSMJwXmDLqPbb9xTT3KVV/UMsCQBU1ciIH1l8kBLC+QQVjjQWogWjuqTWZWODkRE+76Yw /U1BOlGANkOSsxtusMnJnJxl0SpACsUWkTql0L3auP0Xt3KzY8ynKCQ/ZJ9+o1K9mp/oLyFaL+uN/ Vt90mhVERLgeGfyf43HXBnHFIAFk72ecQ1WRjgtA4Z3ACP6DSuWNbUliF3EKfovYt9wopE3nfSWEE kPsWXJeLybZ8cw==; Date: Sun, 22 Jun 2025 11:18:16 +0300 Message-Id: <86msa0gpfb.fsf@gnu.org> From: Eli Zaretskii To: Jacek =?utf-8?Q?=C5=9Awierk?= In-Reply-To: (message from Jacek =?utf-8?Q?=C5=9Awierk?= on Sat, 21 Jun 2025 22:30:02 +0200) Subject: Re: bug#78814: 31.0.50; problems setting custom c++-ts-mode indent style References: <864iw9jvvt.fsf@gnu.org> <86plexi285.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78814-done Cc: 78814-done@debbugs.gnu.org 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: Sat, 21 Jun 2025 22:30:02 +0200 > Cc: 78814@debbugs.gnu.org > > Yes, works like charm. Thanks, now installed on the master branch, and closing the bug. ------------=_1750580342-4721-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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: "=?UTF-8?Q?Jacek_=C5=9Awierk?=" X-Google-Original-From: =?UTF-8?Q?Jacek_=C5=9Awierk?= Message-ID: Date: Tue, 17 Jun 2025 07:17:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: bug-gnu-emacs@gnu.org Subject: 31.0.50; problems setting custom c++-ts-mode indent style 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-Debbugs-Envelope-To: submit 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)) ------------=_1750580342-4721-1--