summaryrefslogtreecommitdiff
path: root/lisp/progmodes/ruby-mode.el
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2023-01-03 06:30:17 +0100
committerStefan Kangas <stefankangas@gmail.com>2023-01-03 06:30:17 +0100
commit55e41707ea727ea4b5c4d3c85f68b62e32dcdfb5 (patch)
tree436b76d5358aa17d126090d63691a7661cc93f20 /lisp/progmodes/ruby-mode.el
parent2ee6012b3faaf12710ec63626795148caeef0f6a (diff)
parent6dd3e352f44eb402c9b76c8f6e5bef032317cc55 (diff)
downloademacs-55e41707ea727ea4b5c4d3c85f68b62e32dcdfb5.tar.gz
emacs-55e41707ea727ea4b5c4d3c85f68b62e32dcdfb5.tar.bz2
emacs-55e41707ea727ea4b5c4d3c85f68b62e32dcdfb5.zip
Merge from origin/emacs-29
6dd3e352f44 Extract common code into ruby-base-mode to derive from 94e330243e1 ruby-ts-mode: Indentation fixes 9b24417dda8 ruby-ts--font-lock-settings: Use more standard faces 9e6536e4d96 ruby-ts-mode: Standardize the string literal highlights 1a9a1fdebf6 Improve fontification in java-ts-mode (bug#60492) dfdf9c21cbe Fontification improvements in typescript-ts-mode (bug#60500) 68e68dfeefe Improve fontification consistency in js-ts-mode (bug#60503) aef869e74f4 ; Update tree-sitter manual 4ef12cfb1fc ; Fix tree-sitter manual title case aab8ddca5e1 ; nt/INSTALL: Update for Emacs 29. 809fbb0e8c4 ; Update copyright notice in tramp-sh.el f8f5202487c (typescript/tsx-ts-mode): Split font-lock feature list in... a86a213e1ac js-ts-mode: Move 'string-interpolation' to font-lock level 3 d26b523886e Fix shrinking of the tab-bar 3f7ea621b90 ; Fix typos in ruby-ts-mode.el 9599b054316 ; Skip ruby-ts tests if grammar is not available ff35ac9dfab Fix default-port regression in erc-select-read-args b7ad0b40148 ; Clarify doc strings of 'call-process' and 'call-process...
Diffstat (limited to 'lisp/progmodes/ruby-mode.el')
-rw-r--r--lisp/progmodes/ruby-mode.el61
1 files changed, 34 insertions, 27 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 14cdf0a1a26..2e8d335f151 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -899,24 +899,6 @@ This only affects the output of the command `ruby-toggle-block'."
(while (and (setq state (apply #'ruby-parse-partial end state))
(>= (nth 2 state) 0) (< (point) end))))))
-(defun ruby-mode-variables ()
- "Set up initial buffer-local variables for Ruby mode."
- (setq indent-tabs-mode ruby-indent-tabs-mode)
- (smie-setup ruby-smie-grammar #'ruby-smie-rules
- :forward-token #'ruby-smie--forward-token
- :backward-token #'ruby-smie--backward-token)
- (unless ruby-use-smie
- (setq-local indent-line-function #'ruby-indent-line))
- (setq-local comment-start "# ")
- (setq-local comment-end "")
- (setq-local comment-column ruby-comment-column)
- (setq-local comment-start-skip "#+ *")
- (setq-local parse-sexp-ignore-comments t)
- (setq-local parse-sexp-lookup-properties t)
- (setq-local paragraph-start (concat "$\\|" page-delimiter))
- (setq-local paragraph-separate paragraph-start)
- (setq-local paragraph-ignore-fill-prefix t))
-
(defun ruby--insert-coding-comment (encoding)
"Insert a magic coding comment for ENCODING.
The style of the comment is controlled by `ruby-encoding-magic-comment-style'."
@@ -2629,29 +2611,54 @@ If there is no Rubocop config file, Rubocop will be passed a flag
"Value for `prettify-symbols-alist' in `ruby-mode'.")
;;;###autoload
-(define-derived-mode ruby-mode prog-mode "Ruby"
- "Major mode for editing Ruby code."
- (ruby-mode-variables)
+(define-derived-mode ruby-base-mode prog-mode "Ruby"
+ "Generic major mode for editing Ruby.
- (setq-local imenu-create-index-function #'ruby-imenu-create-index)
- (setq-local add-log-current-defun-function #'ruby-add-log-current-method)
- (setq-local beginning-of-defun-function #'ruby-beginning-of-defun)
- (setq-local end-of-defun-function #'ruby-end-of-defun)
+This mode is intended to be inherited by concrete major modes.
+Currently there are `ruby-mode' and `ruby-ts-mode'."
+ (setq indent-tabs-mode ruby-indent-tabs-mode)
+
+ (setq-local comment-start "# ")
+ (setq-local comment-end "")
+ (setq-local comment-column ruby-comment-column)
+ (setq-local comment-start-skip "#+ *")
+
+ (setq-local parse-sexp-ignore-comments t)
+ (setq-local parse-sexp-lookup-properties t)
+
+ (setq-local paragraph-start (concat "$\\|" page-delimiter))
+ (setq-local paragraph-separate paragraph-start)
+ (setq-local paragraph-ignore-fill-prefix t)
;; `outline-regexp' contains the first part of `ruby-indent-beg-re'
(setq-local outline-regexp (concat "^\\s *"
(regexp-opt '("class" "module" "def"))
"\\_>"))
(setq-local outline-level (lambda () (1+ (/ (current-indentation)
- ruby-indent-level))))
+ ruby-indent-level))))
(add-hook 'after-save-hook #'ruby-mode-set-encoding nil 'local)
(add-hook 'electric-indent-functions #'ruby--electric-indent-p nil 'local)
(add-hook 'flymake-diagnostic-functions #'ruby-flymake-auto nil 'local)
+ (setq-local prettify-symbols-alist ruby--prettify-symbols-alist))
+
+;;;###autoload
+(define-derived-mode ruby-mode ruby-base-mode "Ruby"
+ "Major mode for editing Ruby code."
+ (smie-setup ruby-smie-grammar #'ruby-smie-rules
+ :forward-token #'ruby-smie--forward-token
+ :backward-token #'ruby-smie--backward-token)
+ (unless ruby-use-smie
+ (setq-local indent-line-function #'ruby-indent-line))
+
+ (setq-local imenu-create-index-function #'ruby-imenu-create-index)
+ (setq-local add-log-current-defun-function #'ruby-add-log-current-method)
+ (setq-local beginning-of-defun-function #'ruby-beginning-of-defun)
+ (setq-local end-of-defun-function #'ruby-end-of-defun)
+
(setq-local font-lock-defaults '((ruby-font-lock-keywords) nil nil
((?_ . "w"))))
- (setq-local prettify-symbols-alist ruby--prettify-symbols-alist)
(setq-local syntax-propertize-function #'ruby-syntax-propertize))