]> git.eshelyaron.com Git - emacs.git/commitdiff
Define sexp in c-ts-mode more broadly (bug#62302)
authorYuan Fu <casouri@gmail.com>
Thu, 6 Apr 2023 21:47:51 +0000 (14:47 -0700)
committerYuan Fu <casouri@gmail.com>
Wed, 12 Apr 2023 07:02:21 +0000 (00:02 -0700)
* lisp/progmodes/c-ts-mode.el: Define sexp in c/c++-ts-mode as
anything but delimiters.

lisp/progmodes/c-ts-mode.el

index 385e3918842ddceb75c8198c0fbad08a258d8c80..ece20e90a6fcfc88b4f3d4bc89cb85dbb41a306e 100644 (file)
@@ -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.