mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-06 20:29:36 +00:00
Merge from origin/emacs-29
db96b1282f
* lisp/help.el: Use 'C-h C-q' to toggle 'help-quick' wind...489865c21e
; Improve markup of long key sequencesd42c2668cf
; * etc/NEWS: Fix wording of a recently edited entry.7a0eaee198
* lisp/isearch.el: Small fixes.b69bffeec0
* lisp/vc/diff-mode.el (diff-minor-mode-prefix): Replace ...9263847ab7
; * etc/NEWS: Move the paragraph with 'C-u RET' closer to...62fb2dc37d
* doc/emacs/display.texi (Text Scale): Improve section ab...70480d3b6b
* lisp/repeat.el (repeat-echo-function): Suggest 'add-fun...fd48201ffe
* lisp/tab-line.el (tab-line-cache-key-default): More cac...b164660260
* etc/package-keyring.gpg: Update with new keyc0be51389e
; Yet another declare-function to avoid treesit-related w...8676bec51d
; * lisp/treesit.el (treesit--simple-imenu-1): Doc fix; w...2ddc480f44
Warn of absent networks module in ERC19d00fab9a
Avoid "already compiled" warning in erc-compat2d8f7b66bc
; Fix one more treesit byte-compilation warning.2d0a921486
; Avoid treesit-related byte-compiler warnings8503b370be
(python--treesit-settings): Remove duplicate matcherb464e6c490
Make last change of w32 GUI dialogs conditional and rever...eedc9d79ae
Fix tree-sitter typos248c13dcfe
Update tree-sitter major modes to use the new Imenu facilityb39dc7ab27
Add tree-sitter helper functions for Imenuba1ddea9da
Fix treesit--things-around (bug#60355)7512b9025a
; * lisp/treesit.el (treesit-traverse-parent): Remove alias.5326b04198
Improve treesit-node-top-level and treesit-parent-until637f5b164f
; Add "src" to the heuristic sub-directory heuristic8ab6df0c9f
; * lisp/epa-ks.el (epa-ks-do-key-to-fetch): Fix 'when' u...2b55a48d3e
* src/w32menu.c (simple_dialog_show): Use MB_YESNOCANCEL ...8b8b791567
; Improve documentation of TAB/SPC indentation624e382211
; Improve doc strings of some new faces41f12e1019
; * lisp/elide-head.el (elide-head): Doc fix to silence c...e3b4cd0ac1
; * lisp/htmlfontify.el (hfy-text-p): Fix whitespace.1b4dc4691c
Fix htmlfontify.el command injection vulnerability.1fe4b98b4d
Improve support for Scheme R6RS and R7RS libraries (bug#5...2347f37f67
; * test/src/treesit-tests.el: remove dead store (bytecom...a6d961ae2f
Add a new tree-sitter query predicate 'pred'835a80dcc4
; Fix tree-sitter defun testsa14821d615
Improve gnutls-min-prime-bits docstringb14bbd108e
Improve handling of tab-bar height.669160d47b
; * nt/INSTALL.W64: More fixes and updates.26b2ec7cb8
Simplify last change (bug#60311)082fc6e308
Fix 'json-available-p' on MS-Windows6c86faec29
loaddefs-gen: Group results by absolute file named90d7d15f2
; Fix vindexes in parsing.texieb26872837
Fix imenu for c-ts-mode (bug#60296)8f68b6497e
Clean up python-ts-mode font-lock features28f26b11a1
Add comment indent and filling to other tree-sitter major...c6b0282645
; Remove unused function in c-ts-mode6e52a9fcad
; * doc/lispref/modes.texi (Parser-based Font Lock): Mino...2bcd1e9a99
; * doc/lispref/parsing.texi (Retrieving Nodes): Add notice.7c7950fe00
Add maintainer stub for tree-sitter filescf32776622
; * doc/lispref/parsing.texi (Using Parser): Remove delet... # Conflicts: # etc/NEWS # lisp/progmodes/c-ts-mode.el # lisp/progmodes/typescript-ts-mode.el # lisp/treesit.el
This commit is contained in:
commit
dce6791e99
50 changed files with 945 additions and 813 deletions
|
@ -29,10 +29,12 @@
|
|||
|
||||
(require 'treesit)
|
||||
(eval-when-compile (require 'rx))
|
||||
(require 'c-ts-mode) ; For comment indent and filling.
|
||||
|
||||
(declare-function treesit-parser-create "treesit.c")
|
||||
(declare-function treesit-induce-sparse-tree "treesit.c")
|
||||
(declare-function treesit-node-start "treesit.c")
|
||||
(declare-function treesit-node-type "treesit.c")
|
||||
(declare-function treesit-node-child-by-field-name "treesit.c")
|
||||
|
||||
(defcustom java-ts-mode-indent-offset 4
|
||||
|
@ -71,8 +73,9 @@
|
|||
((node-is "}") (and parent parent-bol) 0)
|
||||
((node-is ")") parent-bol 0)
|
||||
((node-is "]") parent-bol 0)
|
||||
((and (parent-is "comment") comment-end) comment-start -1)
|
||||
((parent-is "comment") comment-start-skip 0)
|
||||
((and (parent-is "comment") c-ts-mode--looking-at-star)
|
||||
c-ts-mode--comment-start-after-first-star -1)
|
||||
((parent-is "comment") prev-adaptive-prefix 0)
|
||||
((parent-is "text_block") no-indent)
|
||||
((parent-is "class_body") parent-bol java-ts-mode-indent-offset)
|
||||
((parent-is "interface_body") parent-bol java-ts-mode-indent-offset)
|
||||
|
@ -264,50 +267,6 @@ Return nil if there is no name or if NODE is not a defun node."
|
|||
(treesit-node-child-by-field-name node "name")
|
||||
t))))
|
||||
|
||||
(defun java-ts-mode--imenu-1 (node)
|
||||
"Helper for `java-ts-mode--imenu'.
|
||||
Find string representation for NODE and set marker, then recurse
|
||||
the subtrees."
|
||||
(let* ((ts-node (car node))
|
||||
(subtrees (mapcan #'java-ts-mode--imenu-1 (cdr node)))
|
||||
(name (when ts-node
|
||||
(or (treesit-defun-name ts-node)
|
||||
"Unnamed node")))
|
||||
(marker (when ts-node
|
||||
(set-marker (make-marker)
|
||||
(treesit-node-start ts-node)))))
|
||||
(cond
|
||||
((null ts-node) subtrees)
|
||||
(subtrees
|
||||
`((,name ,(cons name marker) ,@subtrees)))
|
||||
(t
|
||||
`((,name . ,marker))))))
|
||||
|
||||
(defun java-ts-mode--imenu ()
|
||||
"Return Imenu alist for the current buffer."
|
||||
(let* ((node (treesit-buffer-root-node))
|
||||
(class-tree (treesit-induce-sparse-tree
|
||||
node "^class_declaration$" nil 1000))
|
||||
(interface-tree (treesit-induce-sparse-tree
|
||||
node "^interface_declaration$" nil 1000))
|
||||
(enum-tree (treesit-induce-sparse-tree
|
||||
node "^enum_declaration$" nil 1000))
|
||||
(record-tree (treesit-induce-sparse-tree
|
||||
node "^record_declaration$" nil 1000))
|
||||
(method-tree (treesit-induce-sparse-tree
|
||||
node "^method_declaration$" nil 1000))
|
||||
(class-index (java-ts-mode--imenu-1 class-tree))
|
||||
(interface-index (java-ts-mode--imenu-1 interface-tree))
|
||||
(enum-index (java-ts-mode--imenu-1 enum-tree))
|
||||
(record-index (java-ts-mode--imenu-1 record-tree))
|
||||
(method-index (java-ts-mode--imenu-1 method-tree)))
|
||||
(append
|
||||
(when class-index `(("Class" . ,class-index)))
|
||||
(when interface-index `(("Interface" . ,interface-index)))
|
||||
(when enum-index `(("Enum" . ,enum-index)))
|
||||
(when record-index `(("Record" . ,record-index)))
|
||||
(when method-index `(("Method" . ,method-index))))))
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode java-ts-mode prog-mode "Java"
|
||||
"Major mode for editing Java, powered by tree-sitter."
|
||||
|
@ -320,15 +279,7 @@ the subtrees."
|
|||
(treesit-parser-create 'java)
|
||||
|
||||
;; Comments.
|
||||
(setq-local comment-start "// ")
|
||||
(setq-local comment-end "")
|
||||
(setq-local comment-start-skip (rx (or (seq "/" (+ "/"))
|
||||
(seq "/" (+ "*")))
|
||||
(* (syntax whitespace))))
|
||||
(setq-local comment-end-skip
|
||||
(rx (* (syntax whitespace))
|
||||
(group (or (syntax comment-end)
|
||||
(seq (+ "*") "/")))))
|
||||
(c-ts-mode-comment-setup)
|
||||
|
||||
(setq-local treesit-text-type-regexp
|
||||
(regexp-opt '("line_comment"
|
||||
|
@ -363,8 +314,11 @@ the subtrees."
|
|||
( bracket delimiter operator)))
|
||||
|
||||
;; Imenu.
|
||||
(setq-local imenu-create-index-function #'java-ts-mode--imenu)
|
||||
(setq-local which-func-functions nil) ;; Piggyback on imenu
|
||||
(setq-local treesit-simple-imenu-settings
|
||||
'(("Class" "\\`class_declaration\\'" nil nil)
|
||||
("Interface" "\\`interface_declaration\\'" nil nil)
|
||||
("Enum" "\\`record_declaration\\'" nil nil)
|
||||
("Method" "\\`method_declaration\\'" nil nil)))
|
||||
(treesit-major-mode-setup))
|
||||
|
||||
(provide 'java-ts-mode)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue