aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/java-ts-mode.el
diff options
context:
space:
mode:
authorYuan Fu2022-11-27 14:15:57 -0800
committerYuan Fu2022-11-27 14:20:56 -0800
commitd5dc1dbf7cb263d8ff541a0def028c2d7d24f82b (patch)
tree878994bb6bc5c1b6465fd0ba7df0352c5888d853 /lisp/progmodes/java-ts-mode.el
parent849223fba1ef899f90a6edff05bce24b90fbb043 (diff)
downloademacs-d5dc1dbf7cb263d8ff541a0def028c2d7d24f82b.tar.gz
emacs-d5dc1dbf7cb263d8ff541a0def028c2d7d24f82b.zip
Remove treesit-comment-start/end and use comment-start/end-skip
treesit-comment-start/end is unnecessary because of comment-start/end-skip, so they should be removed. Cleanup and set comment-start/end-skip for tree-sitter C-like major modes. I replaced the [ \t]* part in comment-start-skip with (syntax whitespace), which is what comment-end-skip uses. I also added grouping in comment-start-skip to match that of comment-end-skip. * lisp/progmodes/c-ts-mode.el (c-ts-mode) (c++-ts-mode) * lisp/progmodes/csharp-mode.el (csharp-ts-mode) * lisp/progmodes/java-ts-mode.el (java-ts-mode) * lisp/progmodes/js.el (js-ts-mode) * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode): Setup comment-start/end-skip. * lisp/treesit.el (treesit-comment-start) (treesit-comment-end): Remove variables. (treesit-simple-indent-presets): Use comment-start/end-skip instead.
Diffstat (limited to 'lisp/progmodes/java-ts-mode.el')
-rw-r--r--lisp/progmodes/java-ts-mode.el10
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el
index dd3d6d31e02..cf2482bb6ee 100644
--- a/lisp/progmodes/java-ts-mode.el
+++ b/lisp/progmodes/java-ts-mode.el
@@ -29,6 +29,7 @@
29;;; Code: 29;;; Code:
30 30
31(require 'treesit) 31(require 'treesit)
32(eval-when-compile (require 'rx))
32 33
33(declare-function treesit-parser-create "treesit.c") 34(declare-function treesit-parser-create "treesit.c")
34(declare-function treesit-induce-sparse-tree "treesit.c") 35(declare-function treesit-induce-sparse-tree "treesit.c")
@@ -299,10 +300,13 @@ the subtrees."
299 300
300 ;; Comments. 301 ;; Comments.
301 (setq-local comment-start "// ") 302 (setq-local comment-start "// ")
302 (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *")
303 (setq-local comment-end "") 303 (setq-local comment-end "")
304 (setq-local treesit-comment-start (rx "/" (or (+ "/") (+ "*")))) 304 (setq-local comment-start-skip (rx (group "/" (or (+ "/") (+ "*")))
305 (setq-local treesit-comment-end (rx (+ (or "*")) "/")) 305 (* (syntax whitespace))))
306 (setq-local comment-end-skip
307 (rx (* (syntax whitespace))
308 (group (or (syntax comment-end)
309 (seq (+ "*") "/")))))
306 310
307 ;; Indent. 311 ;; Indent.
308 (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) 312 (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules)