]> git.eshelyaron.com Git - emacs.git/commitdiff
Make more granular defun-type-regexp (bug#59873)
authorTheodor Thornhill <theo@thornhill.no>
Wed, 7 Dec 2022 09:07:37 +0000 (10:07 +0100)
committerYuan Fu <casouri@gmail.com>
Sat, 10 Dec 2022 00:46:01 +0000 (16:46 -0800)
We don't want to match local_variable_declaration and others to hit on
beginning-of-defun.  The fix is just to make the regexp a bit more
granular.

* lisp/progmodes/java-ts-mode.el (java-ts-mode): Use regexp-opt to
distinguish more granularly.

lisp/progmodes/java-ts-mode.el

index 23e166ee4c355a160f25b8bda6792c156f2c3420..9155a7fff256954301cb15f3ae7800cf896b7cd3 100644 (file)
@@ -321,7 +321,15 @@ the subtrees."
               (append "{}():;," electric-indent-chars))
 
   ;; Navigation.
-  (setq-local treesit-defun-type-regexp "declaration")
+  (setq-local treesit-defun-type-regexp
+              (regexp-opt '("method_declaration"
+                            "class_declaration"
+                            "record_declaration"
+                            "interface_declaration"
+                            "enum_declaration"
+                            "import_declaration"
+                            "package_declaration"
+                            "module_declaration")))
 
   ;; Font-lock.
   (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings)