[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 480f41c7de 1/2: Add < and > to the syntax table in c++-ts-mode
From: |
Yuan Fu |
Subject: |
emacs-29 480f41c7de 1/2: Add < and > to the syntax table in c++-ts-mode (bug#60049) |
Date: |
Wed, 14 Dec 2022 14:43:08 -0500 (EST) |
branch: emacs-29
commit 480f41c7deb4d3a45a862a5308950b35085f835d
Author: Daniel MartÃn <mardani29@yahoo.es>
Commit: Yuan Fu <casouri@gmail.com>
Add < and > to the syntax table in c++-ts-mode (bug#60049)
* lisp/progmodes/c-ts-mode.el (c++-ts-mode--syntax-table): Add a
specific syntax table for C++. Consider "<" and ">" open/close
delimiters (C++ templates).
(c++-ts-mode): Use the new syntax table.
---
lisp/progmodes/c-ts-mode.el | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 4cf06e10eb..821e8f5fd9 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -83,6 +83,14 @@ follows the form of `treesit-simple-indent-rules'."
table)
"Syntax table for `c-ts-mode'.")
+(defvar c++-ts-mode--syntax-table
+ (let ((table (make-syntax-table c-ts-mode--syntax-table)))
+ ;; Template delimiters.
+ (modify-syntax-entry ?< "(" table)
+ (modify-syntax-entry ?> ")" table)
+ table)
+ "Syntax table for `c++-ts-mode'.")
+
(defun c-ts-mode--indent-styles (mode)
"Indent rules supported by `c-ts-mode'.
MODE is either `c' or `cpp'."
@@ -616,6 +624,7 @@ the subtrees."
(define-derived-mode c++-ts-mode c-ts-base-mode "C++"
"Major mode for editing C++, powered by tree-sitter."
:group 'c++
+ :syntax-table c++-ts-mode--syntax-table
(unless (treesit-ready-p 'cpp)
(error "Tree-sitter for C++ isn't available"))