summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/ruby-mode.el18
-rw-r--r--test/lisp/progmodes/ruby-mode-resources/ruby.rb8
2 files changed, 19 insertions, 7 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 45b0f84e332..7d72a783033 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -401,7 +401,10 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'."
(or (and (bolp)
;; Newline is escaped.
(not (eq (char-before (1- (point))) ?\\)))
- (memq (char-before) '(?\; ?=)))))
+ (eq (char-before) ?\;)
+ (and (eq (char-before) ?=)
+ (eq (syntax-after (1- (point)))
+ (string-to-syntax "."))))))
(defun ruby-smie--implicit-semi-p ()
(save-excursion
@@ -1865,6 +1868,12 @@ It will be properly highlighted even when the call omits parens.")
(3 (unless (nth 8 (syntax-ppss (match-beginning 3)))
(goto-char (match-end 0))
(string-to-syntax "_"))))
+ ;; Symbols ending with '=' (bug#42846).
+ (":[[:alpha:]][[:alnum:]_]*\\(=\\)"
+ (1 (unless (or (nth 8 (syntax-ppss))
+ (eq (char-before (match-beginning 0)) ?:)
+ (eq (char-after (match-end 3)) ?>))
+ (string-to-syntax "_"))))
;; Part of method name when at the end of it.
("[!?]"
(0 (unless (save-excursion
@@ -2181,12 +2190,7 @@ It will be properly highlighted even when the call omits parens.")
(0 font-lock-builtin-face))
;; Symbols.
("\\(^\\|[^:]\\)\\(:@\\{0,2\\}\\(?:\\sw\\|\\s_\\)+\\)"
- (2 font-lock-constant-face)
- (3 (unless (and (eq (char-before (match-end 3)) ?=)
- (eq (char-after (match-end 3)) ?>))
- ;; bug#18644
- font-lock-constant-face)
- nil t))
+ (2 font-lock-constant-face))
;; Special globals.
(,(concat "\\$\\(?:[:\"!@;,/._><\\$?~=*&`'+0-9]\\|-[0adFiIlpvw]\\|"
(regexp-opt '("LOAD_PATH" "LOADED_FEATURES" "PROGRAM_NAME"
diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby.rb b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
index 95928030396..434237cf638 100644
--- a/test/lisp/progmodes/ruby-mode-resources/ruby.rb
+++ b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
@@ -475,3 +475,11 @@ top test(
foo bar, {
tee: qux
}
+
+# Bug#42846, bug#18644
+
+:foo=
+# indent here
+2 = 3
+:foo= if true
+{:abc=>4} # not indented, and '=' is not highlighted