From: "Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: xhcoding <xhcoding@foxmail.com>
Cc: 61635@debbugs.gnu.org
Subject: bug#61635: 30.0.50; c++-ts-mode: "}" indented wrong when a class in namespace
Date: Sun, 19 Feb 2023 23:13:06 +0100 [thread overview]
Message-ID: <m1fsb1b8y5.fsf@yahoo.es> (raw)
In-Reply-To: <tencent_6D9296289B94E673C6416A602D0387F03609@qq.com> (xhcoding@foxmail.com's message of "Sun, 19 Feb 2023 21:01:35 +0800")
[-- 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
next prev parent reply other threads:[~2023-02-19 22:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2023-02-20 14:09 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1fsb1b8y5.fsf@yahoo.es \
--to=bug-gnu-emacs@gnu.org \
--cc=61635@debbugs.gnu.org \
--cc=mardani29@yahoo.es \
--cc=xhcoding@foxmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).