(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)
(choice ,@(mapcar
(lambda (kw) (list 'const kw))
ruby-alignable-keywords))))
- :group 'ruby
:safe 'listp
:version "24.4")
Only has effect when `ruby-use-smie' is t."
:type 'boolean
- :group 'ruby
:safe 'booleanp
:version "24.4")
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?.
(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
"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.
(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
(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 ()
(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)
((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))
(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)
(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
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
;; 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
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)
"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))