summaryrefslogtreecommitdiff
path: root/lisp/progmodes/ruby-mode.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2018-11-02 12:07:12 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2018-11-02 12:07:12 -0400
commitdc7b10e9c452f56a79eb83cd5347e7436fa77e1f (patch)
treef73aadfad5a24e41a0ec5de2412515130bee7fac /lisp/progmodes/ruby-mode.el
parent5b218be0c362316384f5c9ef57a3bef02f742e94 (diff)
downloademacs-dc7b10e9c452f56a79eb83cd5347e7436fa77e1f.tar.gz
* lisp/progmodes/ruby-mode.el: Cosmetic changes
Remove redundant :groups. (ruby-font-lock-syntax-table): Delete var. (ruby-mode): Use font-lock-default's syntax-alist instead.
Diffstat (limited to 'lisp/progmodes/ruby-mode.el')
-rw-r--r--lisp/progmodes/ruby-mode.el57
1 files changed, 19 insertions, 38 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 32130cee8e1..9256dfc17b5 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -217,19 +217,16 @@ This should only be called after matching against `ruby-here-doc-beg-re'."
(defcustom ruby-indent-tabs-mode nil
"Indentation can insert tabs in Ruby mode if this is non-nil."
:type 'boolean
- :group 'ruby
:safe 'booleanp)
(defcustom ruby-indent-level 2
"Indentation of Ruby statements."
:type 'integer
- :group 'ruby
:safe 'integerp)
(defcustom ruby-comment-column (default-value 'comment-column)
"Indentation column of comments."
:type 'integer
- :group 'ruby
:safe 'integerp)
(defconst ruby-alignable-keywords '(if while unless until begin case for def)
@@ -265,7 +262,6 @@ Only has effect when `ruby-use-smie' is t."
(choice ,@(mapcar
(lambda (kw) (list 'const kw))
ruby-alignable-keywords))))
- :group 'ruby
:safe 'listp
:version "24.4")
@@ -277,7 +273,6 @@ of its parent.
Only has effect when `ruby-use-smie' is t."
:type 'boolean
- :group 'ruby
:safe 'booleanp
:version "24.4")
@@ -286,7 +281,6 @@ Only has effect when `ruby-use-smie' is t."
Also ignores spaces after parenthesis when `space'.
Only has effect when `ruby-use-smie' is nil."
:type 'boolean
- :group 'ruby
:safe 'booleanp)
;; FIXME Woefully under documented. What is the point of the last t?.
@@ -301,14 +295,12 @@ Only has effect when `ruby-use-smie' is nil."
(cons character (choice (const nil)
(const t)))
(const t) ; why?
- )))
- :group 'ruby)
+ ))))
(defcustom ruby-deep-indent-paren-style 'space
"Default deep indent style.
Only has effect when `ruby-use-smie' is nil."
- :type '(choice (const t) (const nil) (const space))
- :group 'ruby)
+ :type '(choice (const t) (const nil) (const space)))
(defcustom ruby-encoding-map
'((us-ascii . nil) ;; Do not put coding: us-ascii
@@ -318,8 +310,7 @@ Only has effect when `ruby-use-smie' is nil."
"Alist to map encoding name from Emacs to Ruby.
Associating an encoding name with nil means it needs not be
explicitly declared in magic comment."
- :type '(repeat (cons (symbol :tag "From") (symbol :tag "To")))
- :group 'ruby)
+ :type '(repeat (cons (symbol :tag "From") (symbol :tag "To"))))
(defcustom ruby-insert-encoding-magic-comment t
"Insert a magic Ruby encoding comment upon save if this is non-nil.
@@ -336,14 +327,12 @@ even if it's not required."
(const :tag "Emacs Style" emacs)
(const :tag "Ruby Style" ruby)
(const :tag "Custom Style" custom))
- :group 'ruby
:version "24.4")
(defcustom ruby-custom-encoding-magic-comment-template "# encoding: %s"
"A custom encoding comment template.
It is used when `ruby-encoding-magic-comment-style' is set to `custom'."
:type 'string
- :group 'ruby
:version "24.4")
(defcustom ruby-use-encoding-map t
@@ -741,7 +730,7 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'."
(back-to-indentation)
(narrow-to-region (point) end)
(smie-forward-sexp))
- (while (and (setq state (apply 'ruby-parse-partial end state))
+ (while (and (setq state (apply #'ruby-parse-partial end state))
(>= (nth 2 state) 0) (< (point) end))))))
(defun ruby-mode-variables ()
@@ -751,7 +740,7 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'."
(smie-setup ruby-smie-grammar #'ruby-smie-rules
:forward-token #'ruby-smie--forward-token
:backward-token #'ruby-smie--backward-token)
- (setq-local indent-line-function 'ruby-indent-line))
+ (setq-local indent-line-function #'ruby-indent-line))
(setq-local comment-start "# ")
(setq-local comment-end "")
(setq-local comment-column ruby-comment-column)
@@ -986,6 +975,7 @@ delimiter."
((eq c ?\( ) ruby-deep-arglist)))
(defun ruby-parse-partial (&optional end in-string nest depth pcol indent)
+ ;; FIXME: Document why we can't just use parse-partial-sexp.
"TODO: document throughout function body."
(or depth (setq depth 0))
(or indent (setq indent 0))
@@ -1160,7 +1150,7 @@ delimiter."
(state (list in-string nest depth pcol indent)))
;; parse the rest of the line
(while (and (> line-end-position (point))
- (setq state (apply 'ruby-parse-partial
+ (setq state (apply #'ruby-parse-partial
line-end-position state))))
(setq in-string (car state)
nest (nth 1 state)
@@ -1197,7 +1187,7 @@ delimiter."
(save-restriction
(narrow-to-region (point) end)
(while (and (> end (point))
- (setq state (apply 'ruby-parse-partial end state))))))
+ (setq state (apply #'ruby-parse-partial end state))))))
(list (nth 0 state) ; in-string
(car (nth 1 state)) ; nest
(nth 2 state) ; depth
@@ -2034,13 +2024,6 @@ It will be properly highlighted even when the call omits parens.")
context)))
t)))
-(defvar ruby-font-lock-syntax-table
- (let ((tbl (make-syntax-table ruby-mode-syntax-table)))
- (modify-syntax-entry ?_ "w" tbl)
- tbl)
- "The syntax table to use for fontifying Ruby mode buffers.
-See `font-lock-syntax-table'.")
-
(defconst ruby-font-lock-keyword-beg-re "\\(?:^\\|[^.@$:]\\|\\.\\.\\)")
(defconst ruby-font-lock-keywords
@@ -2219,7 +2202,8 @@ See `font-lock-syntax-table'.")
;; Conversion methods on Kernel.
(,(concat ruby-font-lock-keyword-beg-re
(regexp-opt '("Array" "Complex" "Float" "Hash"
- "Integer" "Rational" "String") 'symbols))
+ "Integer" "Rational" "String")
+ 'symbols))
(1 font-lock-builtin-face))
;; Expression expansion.
(ruby-match-expression-expansion
@@ -2316,14 +2300,12 @@ See `font-lock-syntax-table'.")
Only takes effect if RuboCop is installed."
:version "26.1"
:type 'boolean
- :group 'ruby
:safe 'booleanp)
(defcustom ruby-rubocop-config ".rubocop.yml"
"Configuration file for `ruby-flymake-rubocop'."
:version "26.1"
:type 'string
- :group 'ruby
:safe 'stringp)
(defun ruby-flymake-rubocop (report-fn &rest _args)
@@ -2393,18 +2375,17 @@ Only takes effect if RuboCop is installed."
"Major mode for editing Ruby code."
(ruby-mode-variables)
- (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 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)
- (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)
+ (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 font-lock-defaults '((ruby-font-lock-keywords) nil nil))
- (setq-local font-lock-keywords ruby-font-lock-keywords)
- (setq-local font-lock-syntax-table ruby-font-lock-syntax-table)
+ (setq-local font-lock-defaults '((ruby-font-lock-keywords) nil nil
+ ((?_ . "w"))))
(setq-local syntax-propertize-function #'ruby-syntax-propertize))