* bug#60047: [PATCH] Treat C++ classes as defuns in C Tree-sitter mode
[not found] <m1sfhj6nkj.fsf.ref@yahoo.es>
@ 2022-12-13 20:44 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-14 2:12 ` Yuan Fu
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-13 20:44 UTC (permalink / raw)
To: 60047
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
Tags: patch
The attached patch makes C-M-a/C-M-e inside a C++ class definition in
c++-ts-mode go to the beginning or the end of the class, respectively.
I've added it to the base mode because I think it's harmless for C, and
it can be convenient if we implement an Obj-C mode based on Tree-sitter.
Thanks.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Treat-C-classes-as-defuns-in-C-Tree-sitter-mode.patch --]
[-- Type: text/patch, Size: 1062 bytes --]
From 008ce6794281fd606df8161af5ed65b267be0664 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Tue, 13 Dec 2022 21:35:40 +0100
Subject: [PATCH] Treat C++ classes as defuns in C Tree-sitter mode
* lisp/progmodes/c-ts-mode.el (c-ts-base-mode): Add "class_specifier"
as a node of type "defun".
---
lisp/progmodes/c-ts-mode.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 0d0a14e933..8407be3b6b 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -553,7 +553,8 @@ c-ts-base-mode
"type_definition"
"struct_specifier"
"enum_specifier"
- "union_specifier")))
+ "union_specifier"
+ "class_specifier")))
;; Nodes like struct/enum/union_specifier can appear in
;; function_definitions, so we need to find the top-level node.
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread