Add non-TS modes as extra parent of TS modes (bug#68246)
Record the fact that TS modes are alternatives to the non-TS modes using the new `derived-mode-add-parents` functionality. Do the same for long standing similar issues with CPerl-mode. * lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode): * lisp/textmodes/toml-ts-mode.el (toml-ts-mode): * lisp/textmodes/html-ts-mode.el (html-ts-mode): * lisp/textmodes/css-mode.el (css-ts-mode): * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode, tsx-ts-mode): * lisp/progmodes/sh-script.el (bash-ts-mode): * lisp/progmodes/rust-ts-mode.el (rust-ts-mode): * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): * lisp/progmodes/python.el (python-ts-mode): * lisp/progmodes/lua-ts-mode.el (lua-ts-mode): * lisp/progmodes/json-ts-mode.el (json-ts-mode): * lisp/progmodes/js.el (js-ts-mode): * lisp/progmodes/java-ts-mode.el (java-ts-mode): * lisp/progmodes/heex-ts-mode.el (heex-ts-mode): * lisp/progmodes/go-ts-mode.el (go-ts-mode, go-mod-ts-mode): * lisp/progmodes/elixir-ts-mode.el (elixir-ts-mode): * lisp/progmodes/dockerfile-ts-mode.el (dockerfile-ts-mode): * lisp/progmodes/csharp-mode.el (csharp-ts-mode): * lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode): * lisp/progmodes/c-ts-mode.el (c-ts-mode, c++-ts-mode): Add non-TS mode as extra parent. * lisp/progmodes/cperl-mode.el (cperl-mode): Add `perl-mode` as extra parent.
This commit is contained in:
parent
454a55dbd9
commit
c79a509384
22 changed files with 58 additions and 0 deletions
10
etc/NEWS
10
etc/NEWS
|
@ -62,6 +62,16 @@ more details.
|
|||
|
||||
* Incompatible Changes in Emacs 30.1
|
||||
|
||||
** Tree-Sitter modes are now declared as submodes of the non-TS modes.
|
||||
In order to help the use of those Tree-Sitter modes, they are now
|
||||
declared to have the corresponding non-Tree-Sitter mode as an
|
||||
additional parent.
|
||||
This way, things like `.dir-locals.el` settings, and YASnippet
|
||||
collections of snippets automatically apply to the new Tree-Sitter modes.
|
||||
|
||||
Note that those modes still do not inherit from the non-TS mode, so
|
||||
configuration settings installed via mode hooks are not affected.
|
||||
|
||||
+++
|
||||
** URL now never sends user email addresses in HTTP requests.
|
||||
Emacs never sent email addresses by default, but it used to be
|
||||
|
|
|
@ -1328,6 +1328,8 @@ in your configuration."
|
|||
(lambda (_pos) 'c))
|
||||
(treesit-font-lock-recompute-features '(emacs-devel)))))
|
||||
|
||||
(derived-mode-add-parents 'c-ts-mode '(c-mode))
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode c++-ts-mode c-ts-base-mode "C++"
|
||||
"Major mode for editing C++, powered by tree-sitter.
|
||||
|
@ -1371,6 +1373,8 @@ recommended to enable `electric-pair-mode' with this mode."
|
|||
(setq-local add-log-current-defun-function
|
||||
#'c-ts-mode--emacs-current-defun-name))))
|
||||
|
||||
(derived-mode-add-parents 'c++-ts-mode '(c++-mode))
|
||||
|
||||
(easy-menu-define c-ts-mode-menu (list c-ts-mode-map c++-ts-mode-map)
|
||||
"Menu for `c-ts-mode' and `c++-ts-mode'."
|
||||
'("C/C++"
|
||||
|
|
|
@ -243,6 +243,8 @@ Return nil if there is no name or if NODE is not a defun node."
|
|||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'cmake-ts-mode '(cmake-mode))
|
||||
|
||||
(if (treesit-ready-p 'cmake)
|
||||
(add-to-list 'auto-mode-alist
|
||||
'("\\(?:CMakeLists\\.txt\\|\\.cmake\\)\\'" . cmake-ts-mode)))
|
||||
|
|
|
@ -1934,6 +1934,8 @@ or as help on variables `cperl-tips', `cperl-problems',
|
|||
;; Setup Flymake
|
||||
(add-hook 'flymake-diagnostic-functions #'perl-flymake nil t))
|
||||
|
||||
(derived-mode-add-parents 'cperl-mode '(perl-mode))
|
||||
|
||||
(defun cperl--set-file-style ()
|
||||
(when cperl-file-style
|
||||
(cperl-file-style cperl-file-style)))
|
||||
|
|
|
@ -998,6 +998,8 @@ Key bindings:
|
|||
|
||||
(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-ts-mode)))
|
||||
|
||||
(derived-mode-add-parents 'csharp-ts-mode '(csharp-mode))
|
||||
|
||||
(provide 'csharp-mode)
|
||||
|
||||
;;; csharp-mode.el ends here
|
||||
|
|
|
@ -165,6 +165,8 @@ Return nil if there is no name or if NODE is not a stage node."
|
|||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'dockerfile-ts-mode '(dockerfile-mode))
|
||||
|
||||
(if (treesit-ready-p 'dockerfile)
|
||||
(add-to-list 'auto-mode-alist
|
||||
;; NOTE: We can't use `rx' here, as it breaks bootstrap.
|
||||
|
|
|
@ -753,6 +753,8 @@ Return nil if NODE is not a defun node or doesn't have a name."
|
|||
(treesit-major-mode-setup)
|
||||
(setq-local syntax-propertize-function #'elixir-ts--syntax-propertize)))
|
||||
|
||||
(derived-mode-add-parents 'elixir-ts-mode '(elixir-mode))
|
||||
|
||||
(if (treesit-ready-p 'elixir)
|
||||
(progn
|
||||
(add-to-list 'auto-mode-alist '("\\.elixir\\'" . elixir-ts-mode))
|
||||
|
|
|
@ -261,6 +261,8 @@
|
|||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'go-ts-mode '(go-mode))
|
||||
|
||||
(if (treesit-ready-p 'go)
|
||||
;; FIXME: Should we instead put `go-mode' in `auto-mode-alist'
|
||||
;; and then use `major-mode-remap-defaults' to map it to `go-ts-mode'?
|
||||
|
@ -439,6 +441,8 @@ what the parent of the node would be if it were a node."
|
|||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'go-mod-ts-mode '(go-mod-mode))
|
||||
|
||||
(if (treesit-ready-p 'gomod)
|
||||
(add-to-list 'auto-mode-alist '("/go\\.mod\\'" . go-mod-ts-mode)))
|
||||
|
||||
|
|
|
@ -187,6 +187,8 @@ With ARG, do it many times. Negative ARG means move backward."
|
|||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'heex-ts-mode '(heex-mode))
|
||||
|
||||
(if (treesit-ready-p 'heex)
|
||||
;; Both .heex and the deprecated .leex files should work
|
||||
;; with the tree-sitter-heex grammar.
|
||||
|
|
|
@ -406,6 +406,8 @@ Return nil if there is no name or if NODE is not a defun node."
|
|||
("Method" "\\`method_declaration\\'" nil nil)))
|
||||
(treesit-major-mode-setup))
|
||||
|
||||
(derived-mode-add-parents 'java-ts-mode '(java-mode))
|
||||
|
||||
(if (treesit-ready-p 'java)
|
||||
(add-to-list 'auto-mode-alist '("\\.java\\'" . java-ts-mode)))
|
||||
|
||||
|
|
|
@ -3916,6 +3916,8 @@ See `treesit-thing-settings' for more information.")
|
|||
(add-to-list 'auto-mode-alist
|
||||
'("\\(\\.js[mx]\\|\\.har\\)\\'" . js-ts-mode))))
|
||||
|
||||
(derived-mode-add-parents 'js-ts-mode '(js-mode))
|
||||
|
||||
(defvar js-ts--s-p-query
|
||||
(when (treesit-available-p)
|
||||
(treesit-query-compile 'javascript
|
||||
|
|
|
@ -164,6 +164,8 @@ Return nil if there is no name or if NODE is not a defun node."
|
|||
|
||||
(treesit-major-mode-setup))
|
||||
|
||||
(derived-mode-add-parents 'json-ts-mode '(json-mode))
|
||||
|
||||
(if (treesit-ready-p 'json)
|
||||
(add-to-list 'auto-mode-alist
|
||||
'("\\.json\\'" . json-ts-mode)))
|
||||
|
|
|
@ -798,6 +798,8 @@ Calls REPORT-FN directly."
|
|||
|
||||
(add-hook 'flymake-diagnostic-functions #'lua-ts-flymake-luacheck nil 'local))
|
||||
|
||||
(derived-mode-add-parents 'lua-ts-mode '(lua-mode))
|
||||
|
||||
(when (treesit-ready-p 'lua)
|
||||
(add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-ts-mode)))
|
||||
|
||||
|
|
|
@ -7128,6 +7128,8 @@ implementations: `python-mode' and `python-ts-mode'."
|
|||
(add-to-list 'auto-mode-alist '("\\.py[iw]?\\'" . python-ts-mode))
|
||||
(add-to-list 'interpreter-mode-alist '("python[0-9.]*" . python-ts-mode))))
|
||||
|
||||
(derived-mode-add-parents 'python-ts-mode '(python-mode))
|
||||
|
||||
;;; Completion predicates for M-x
|
||||
;; Commands that only make sense when editing Python code.
|
||||
(dolist (sym '(python-add-import
|
||||
|
|
|
@ -1210,6 +1210,8 @@ leading double colon is not added."
|
|||
|
||||
(setq-local syntax-propertize-function #'ruby-ts--syntax-propertize))
|
||||
|
||||
(derived-mode-add-parents 'ruby-ts-mode '(ruby-mode))
|
||||
|
||||
(if (treesit-ready-p 'ruby)
|
||||
(add-to-list 'major-mode-remap-defaults
|
||||
'(ruby-mode . ruby-ts-mode)))
|
||||
|
|
|
@ -474,6 +474,8 @@ See `prettify-symbols-compose-predicate'."
|
|||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'rust-ts-mode '(rust-mode))
|
||||
|
||||
(if (treesit-ready-p 'rust)
|
||||
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-ts-mode)))
|
||||
|
||||
|
|
|
@ -1639,6 +1639,8 @@ not written in Bash or sh."
|
|||
(setq-local treesit-defun-type-regexp "function_definition")
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'bash-ts-mode '(sh-mode))
|
||||
|
||||
(advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode
|
||||
;; Give it lower precedence than normal advice, so other
|
||||
;; advices take precedence over it.
|
||||
|
|
|
@ -505,6 +505,8 @@ This mode is intended to be inherited by concrete major modes."
|
|||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'typescript-ts-mode '(typescript-mode))
|
||||
|
||||
(if (treesit-ready-p 'typescript)
|
||||
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-ts-mode)))
|
||||
|
||||
|
@ -562,6 +564,8 @@ at least 3 (which is the default value)."
|
|||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'tsx-ts-mode '(tsx-mode))
|
||||
|
||||
(defvar typescript-ts--s-p-query
|
||||
(when (treesit-available-p)
|
||||
(treesit-query-compile 'typescript
|
||||
|
|
|
@ -1830,6 +1830,8 @@ can also be used to fill comments.
|
|||
|
||||
(add-to-list 'auto-mode-alist '("\\.css\\'" . css-ts-mode))))
|
||||
|
||||
(derived-mode-add-parents 'css-ts-mode '(css-mode))
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode css-mode css-base-mode "CSS"
|
||||
"Major mode to edit Cascading Style Sheets (CSS).
|
||||
|
|
|
@ -134,6 +134,8 @@ Return nil if there is no name or if NODE is not a defun node."
|
|||
|
||||
(treesit-major-mode-setup))
|
||||
|
||||
(derived-mode-add-parents 'html-ts-mode '(html-mode))
|
||||
|
||||
(if (treesit-ready-p 'html)
|
||||
(add-to-list 'auto-mode-alist '("\\.html\\'" . html-ts-mode)))
|
||||
|
||||
|
|
|
@ -153,6 +153,8 @@ Return nil if there is no name or if NODE is not a defun node."
|
|||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'toml-ts-mode '(toml-mode))
|
||||
|
||||
(if (treesit-ready-p 'toml)
|
||||
(add-to-list 'auto-mode-alist '("\\.toml\\'" . toml-ts-mode)))
|
||||
|
||||
|
|
|
@ -169,6 +169,8 @@ boundaries. JUSTIFY is passed to `fill-paragraph'."
|
|||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(derived-mode-add-parents 'yaml-ts-mode '(yaml-mode))
|
||||
|
||||
(if (treesit-ready-p 'yaml)
|
||||
(add-to-list 'auto-mode-alist '("\\.ya?ml\\'" . yaml-ts-mode)))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue