From 1a5a03c15abf4043cbbabaa5bcbb874fbef69505 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Thu, 6 Apr 2023 14:47:51 -0700 Subject: [PATCH] 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. -- 2.39.2