[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-30 0ef0f18f163: Allow to go back to using 'ruby-mode' after loadin
From: |
Eli Zaretskii |
Subject: |
emacs-30 0ef0f18f163: Allow to go back to using 'ruby-mode' after loading 'ruby-ts-mode' |
Date: |
Thu, 28 Nov 2024 09:56:22 -0500 (EST) |
branch: emacs-30
commit 0ef0f18f163c37a9d5c0b63c34eb3f37016a0d5e
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Allow to go back to using 'ruby-mode' after loading 'ruby-ts-mode'
* lisp/progmodes/ruby-ts-mode.el (major-mode-remap-defaults):
Remap 'ruby-mode' to 'ruby-ts-mode'. Add commentary.
* lisp/progmodes/ruby-mode.el (major-mode-remap-defaults): Remove
any remappings of ruby-mode'.
* lisp/progmodes/c-ts-mode.el: Fix a typo in a comment. (Bug#74339)
---
lisp/progmodes/c-ts-mode.el | 2 +-
lisp/progmodes/ruby-mode.el | 4 ++++
lisp/progmodes/ruby-ts-mode.el | 41 ++++++++++++++++++++++++++++++++++++-----
3 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 73c1411ad0f..31f822b219d 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -35,7 +35,7 @@
;; To use these modes by default, assuming you have the respective
;; tree-sitter grammars available, do one of the following:
;;
-;; - Add one or mode of the following to your init file:
+;; - Add one or more of the following lines to your init file:
;;
;; (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode))
;; (add-to-list 'major-mode-remap-alist '(c++-mode . c++-ts-mode))
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index d953ec8b25c..4c37ef45ddf 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -2748,6 +2748,10 @@ Currently there are `ruby-mode' and `ruby-ts-mode'."
(dolist (name (list "ruby" "rbx" "jruby" "j?ruby\\(?:[0-9.]+\\)"))
(add-to-list 'interpreter-mode-alist (cons (purecopy name) 'ruby-mode)))
+;; See ruby-ts-mode.el for why we do this.
+(setq major-mode-remap-defaults
+ (assq-delete-all 'ruby-mode major-mode-remap-defaults))
+
(provide 'ruby-mode)
;;; ruby-mode.el ends here
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index 7c1c07ac5b6..c86ef7e0a3e 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -34,9 +34,38 @@
;; put somewhere Emacs can find it. See the docstring of
;; `treesit-extra-load-path'.
-;; This mode doesn't associate itself with .rb files automatically.
-;; You can do that either by prepending to the value of
-;; `auto-mode-alist', or using `major-mode-remap-alist'.
+;; This mode doesn't associate itself with .rb files automatically. To
+;; use this mode by default, assuming you have the tree-sitter grammar
+;; available, do one of the following:
+;;
+;; - Add the following to your init file:
+;;
+;; (add-to-list 'major-mode-remap-alist '(ruby-mode . ruby-ts-mode))
+;;
+;; - Customize 'auto-mode-alist' to turn ruby-ts-mode automatically.
+;; For example:
+;;
+;; (add-to-list 'auto-mode-alist
+;; (cons (concat "\\(?:\\.\\(?:"
+;; "rbw?\\|ru\\|rake\\|thor\\|axlsx"
+;; "\\|jbuilder\\|rabl\\|gemspec\\|podspec"
+;; "\\)"
+;; "\\|/"
+;; "\\(?:Gem\\|Rake\\|Cap\\|Thor"
+;; "\\|Puppet\\|Berks\\|Brew\\|Fast"
+;; "\\|Vagrant\\|Guard\\|Pod\\)file"
+;; "\\)\\'")
+;; 'ruby-ts-mode))
+;;
+;; will turn on the ruby-ts-mode for Ruby source files.
+;;
+;; - If you have the Ruby grammar installed, add
+;;
+;; (load "ruby-ts-mode")
+;;
+;; to your init file.
+;;
+;; You can also turn on this mode manually in a buffer.
;; Tree Sitter brings a lot of power and versitility which can be
;; broken into these features.
@@ -1234,8 +1263,10 @@ leading double colon is not added."
(derived-mode-add-parents 'ruby-ts-mode '(ruby-mode))
-(if (treesit-ready-p 'ruby)
- (add-to-list 'major-mode-remap-defaults
+(when (treesit-ready-p 'ruby)
+ (setq major-mode-remap-defaults
+ (assq-delete-all 'ruby-mode major-mode-remap-defaults))
+ (add-to-list 'major-mode-remap-defaults
'(ruby-mode . ruby-ts-mode)))
(provide 'ruby-ts-mode)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-30 0ef0f18f163: Allow to go back to using 'ruby-mode' after loading 'ruby-ts-mode',
Eli Zaretskii <=