[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1a5a03c15ab 2/3: Define sexp in c-ts-mode more broadly (bug#62302
From: |
Yuan Fu |
Subject: |
master 1a5a03c15ab 2/3: Define sexp in c-ts-mode more broadly (bug#62302) |
Date: |
Wed, 12 Apr 2023 03:02:44 -0400 (EDT) |
branch: master
commit 1a5a03c15abf4043cbbabaa5bcbb874fbef69505
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Define sexp in c-ts-mode more broadly (bug#62302)
* lisp/progmodes/c-ts-mode.el: Define sexp in c/c++-ts-mode as
anything but delimiters.
---
lisp/progmodes/c-ts-mode.el | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 385e3918842..ece20e90a6f 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -921,15 +921,13 @@ the semicolon. This function skips the semicolon."
"goto_statement"
"case_statement")))
+ ;; IMO it makes more sense to define what's NOT sexp, since sexp by
+ ;; spirit, especially when used for movement, is like "expression"
+ ;; or "syntax unit". --yuan
(setq-local treesit-sexp-type-regexp
- (regexp-opt '("preproc"
- "declarator"
- "qualifier"
- "type"
- "parameter"
- "expression"
- "literal"
- "string")))
+ ;; It more useful to include semicolons as sexp so that
+ ;; users can move to the end of a statement.
+ (rx (not (or "{" "}" "[" "]" "(" ")" ","))))
;; Nodes like struct/enum/union_specifier can appear in
;; function_definitions, so we need to find the top-level node.