:group 'ruby
:safe 'booleanp)
-;; FIXME Woefully under documented. What is the point of the last `t'?.
+;; FIXME Woefully under documented. What is the point of the last t?.
(defcustom ruby-deep-indent-paren '(?\( ?\[ ?\] t)
"Deep indent lists in parenthesis when non-nil.
The value t means continuous line.
(let ((index-alist '()) (case-fold-search nil)
name next pos decl sing)
(goto-char beg)
- (while (re-search-forward "^\\s *\\(\\(class\\s +\\|\\(class\\s *<<\\s *\\)\\|module\\s +\\)\\([^\(<\n ]+\\)\\|\\(def\\|alias\\)\\s +\\([^\(\n ]+\\)\\)" end t)
+ (while (re-search-forward "^\\s *\\(\\(class\\s +\\|\\(class\\s *<<\\s *\\)\\|module\\s +\\)\\([^(<\n ]+\\)\\|\\(def\\|alias\\)\\s +\\([^(\n ]+\\)\\)" end t)
(setq sing (match-beginning 3))
(setq decl (match-string 5))
(setq next (match-end 0))
(if prefix
(setq name
(cond
- ((string-match "^self\." name)
+ ((string-match "^self\\." name)
(concat (substring prefix 0 -1) (substring name 4)))
(t (concat prefix name)))))
(push (cons name pos) index-alist)
(setq in-string (match-end 0))
(goto-char ruby-indent-point)))
(t
- (error (format "Bad string %s"
- (buffer-substring (point) pnt)
- ))))))
+ (error "Bad string %s" (buffer-substring (point) pnt))))))
(list in-string nest depth pcol))
(defun ruby-parse-region (start end)
(interactive "p")
(ruby-forward-sexp)
(let (case-fold-search)
- (when (looking-back (concat "^\\s *" ruby-block-end-re))
+ (when (looking-back (concat "^\\s *" ruby-block-end-re)
+ (line-beginning-position))
(forward-line 1))))
(defun ruby-beginning-of-indent ()
(setq content
(if (equal string-quote "\"")
(replace-regexp-in-string "\\\\\"" "\"" (replace-regexp-in-string "\\([^\\\\]\\)'" "\\1\\\\'" content))
- (replace-regexp-in-string "\\\\\'" "'" (replace-regexp-in-string "\\([^\\\\]\\)\"" "\\1\\\\\"" content))))
+ (replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string "\\([^\\\\]\\)\"" "\\1\\\\\"" content))))
(let ((orig-point (point)))
(delete-region min max)
(insert
(defvar ruby-syntax-before-regexp-re
(concat
;; Special tokens that can't be followed by a division operator.
- "\\(^\\|[[=(,~;<>]"
+ "\\(^\\|[[{|=(,~;<>!]"
;; Distinguish ternary operator tokens.
;; FIXME: They don't really have to be separated with spaces.
"\\|[?:] "
(t
(error (concat
"Internal error on `ruby-in-ppss-context-p': "
- "context name `" (symbol-name context) "' is unknown"))))
+ "context name `%s' is unknown")
+ context)))
t)))
(defvar ruby-font-lock-syntax-table
"rescue"
"retry"
"return"
- "then"
+ "self"
"super"
+ "then"
"unless"
"undef"
"until"
"at_exit"
"autoload"
"autoload?"
+ "callcc"
"catch"
"eval"
"exec"
- "fork"
"format"
"lambda"
"load"
"sprintf"
"syscall"
"system"
+ "throw"
+ "trace_var"
"trap"
+ "untrace_var"
"warn"
;; keyword-like private methods on Module
"alias_method"
"__dir__"
"__method__"
"abort"
- "at_exit"
"binding"
"block_given?"
"caller"
"exit"
"exit!"
"fail"
+ "fork"
+ "global_variables"
+ "local_variables"
"private"
"protected"
"public"
"readline"
"readlines"
"sleep"
- "srand"
- "throw")
+ "srand")
'symbols))
(1 font-lock-builtin-face))
;; Here-doc beginnings.
"\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$"
;; Variables.
(,(concat ruby-font-lock-keyword-beg-re
- "\\_<\\(nil\\|self\\|true\\|false\\)\\_>")
- 1 font-lock-variable-name-face)
+ "\\_<\\(nil\\|true\\|false\\)\\_>")
+ 1 font-lock-constant-face)
;; Keywords that evaluate to certain values.
("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>"
(0 font-lock-builtin-face))
- ;; Symbols.
- ("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|@?\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
+ ;; Symbols with symbol characters.
+ ("\\(^\\|[^:]\\)\\(:@?\\(?:\\w\\|_\\)+\\)\\([!?=]\\)?"
+ (2 font-lock-constant-face)
+ (3 (unless (and (eq (char-before (match-end 3)) ?=)
+ (eq (char-after (match-end 3)) ?>))
+ ;; bug#18466
+ font-lock-constant-face)
+ nil t))
+ ;; Symbols with special characters.
+ ("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
2 font-lock-constant-face)
;; Special globals.
(,(concat "\\$\\(?:[:\"!@;,/\\._><\\$?~=*&`'+0-9]\\|-[0adFiIlpvw]\\|"
;; Constants.
("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)"
1 (unless (eq ?\( (char-after)) font-lock-type-face))
- ("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]"
- (2 font-lock-constant-face))
+ ;; Ruby 1.9-style symbol hash keys.
+ ("\\(?:^\\s *\\|[[{(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+:\\)[^:]"
+ (1 (progn (forward-char -1) font-lock-constant-face)))
;; Conversion methods on Kernel.
(,(concat ruby-font-lock-keyword-beg-re
(regexp-opt '("Array" "Complex" "Float" "Hash"
;;;###autoload
(add-to-list 'auto-mode-alist
- (cons (purecopy (concat "\\(?:\\."
- "rb\\|ru\\|rake\\|thor"
+ (cons (purecopy (concat "\\(?:\\.\\(?:"
+ "rbw?\\|ru\\|rake\\|thor"
"\\|jbuilder\\|rabl\\|gemspec\\|podspec"
+ "\\)"
"\\|/"
"\\(?:Gem\\|Rake\\|Cap\\|Thor"
"\\|Puppet\\|Berks"