* bug#61635: 30.0.50; c++-ts-mode: "}" indented wrong when a class in namespace
@ 2023-02-19 13:01 xhcoding
2023-02-19 22:13 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 3+ messages in thread
From: xhcoding @ 2023-02-19 13:01 UTC (permalink / raw)
To: 61635
The closing '};' is indented wrong in the following class/struct definition:
namespace test {
class Name {
}; <-- error indent
} <-- when press tab, minibuffer output "Wrong type argument: wholenump, -2"
In GNU Emacs 30.0.50 (build 5, x86_64-w64-mingw32)
Repository revision: 07a76a06f9a438e2a1bf1e565e3e78f7927c37f2
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 10.0.22621
System Description: Microsoft Windows 10 Home China (v10.0.2009.22621.1105)
Configured using:
'configure --prefix=/d/emacs-build/pkg/master-x86_64 'CFLAGS=-Ofast -fno-finite-math-only -fomit-frame-pointer'
--with-zlib --with-xpm --with-xml2 --with-tree-sitter --without-tiff --with-rsvg --with-png --with-lcms2 --with-json
--with-jpeg --with-harfbuzz --with-gnutls --with-gif --without-cairo --disable-build-details --without-dbus
--with-compress-install --with-small-ja-dic'
Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB
Important settings:
value of $LANG: CHS
locale-coding-system: cp936
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#61635: 30.0.50; c++-ts-mode: "}" indented wrong when a class in namespace
2023-02-19 13:01 bug#61635: 30.0.50; c++-ts-mode: "}" indented wrong when a class in namespace xhcoding
@ 2023-02-19 22:13 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-20 14:09 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-02-19 22:13 UTC (permalink / raw)
To: xhcoding; +Cc: 61635
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
tags 61635 + patch
quit
xhcoding <xhcoding@foxmail.com> writes:
> The closing '};' is indented wrong in the following class/struct definition:
>
> namespace test {
> class Name {
> }; <-- error indent
>
> } <-- when press tab, minibuffer output "Wrong type argument: wholenump, -2"
>
>
The attached patch fixes the problem by considering "declaration_list"
nodes as "blocks".
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-declaration_list-to-c-ts-common-indent-type-rege.patch --]
[-- Type: text/x-patch, Size: 1909 bytes --]
From 1435efef0e3c6af871f97be9553a92cd125f4ffb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sun, 19 Feb 2023 22:57:54 +0100
Subject: [PATCH] Add declaration_list to c-ts-common-indent-type-regexp-alist
* lisp/progmodes/c-ts-mode.el (c-ts-base-mode): Consider a
"declaration_list" a block. (Bug#61635)
* test/lisp/progmodes/c-ts-mode-resources/indent.erts (Code): Add a
test case.
---
lisp/progmodes/c-ts-mode.el | 3 ++-
.../progmodes/c-ts-mode-resources/indent.erts | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index a60c464093e..43b88cd57b1 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -774,7 +774,8 @@ c-ts-base-mode
`((block . ,(rx (or "compound_statement"
"field_declaration_list"
"enumerator_list"
- "initializer_list")))
+ "initializer_list"
+ "declaration_list")))
(if . "if_statement")
(else . ("if_statement" . "alternative"))
(do . "do_statement")
diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
index 05d59c10a42..a4f700e7c79 100644
--- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
@@ -354,3 +354,19 @@ int main()
};
}
=-=-=
+
+Code:
+ (lambda ()
+ (c++-ts-mode)
+ (setq-local indent-tabs-mode nil)
+ (setq-local c-ts-mode-indent-offset 2)
+ (indent-region (point-min) (point-max)))
+
+Name: Declaration List (Namespace) (Bug#61635)
+
+=-=
+namespace test {
+ class Name {
+ };
+}
+=-=-=
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#61635: 30.0.50; c++-ts-mode: "}" indented wrong when a class in namespace
2023-02-19 22:13 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-02-20 14:09 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 3+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-02-20 14:09 UTC (permalink / raw)
To: Daniel Martín; +Cc: 61635, xhcoding
Daniel Martín <mardani29@yahoo.es> writes:
> tags 61635 + patch
> quit
>
> xhcoding <xhcoding@foxmail.com> writes:
>
>> The closing '};' is indented wrong in the following class/struct definition:
>>
>> namespace test {
>> class Name {
>> }; <-- error indent
>>
>> } <-- when press tab, minibuffer output "Wrong type argument: wholenump, -2"
>>
>>
Thanks! Installed and pushed :-)
Theo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-20 14:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-19 13:01 bug#61635: 30.0.50; c++-ts-mode: "}" indented wrong when a class in namespace xhcoding
2023-02-19 22:13 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-20 14:09 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
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).