summaryrefslogtreecommitdiff
path: root/lisp/progmodes/ruby-mode.el
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2020-12-31 18:39:22 +0200
committerDmitry Gutov <dgutov@yandex.ru>2020-12-31 18:39:41 +0200
commitb47b98bc4b2b6f901865b7530145766a0f8da142 (patch)
treee06e9a16ba1562cfd628447fff39a93313dd6e36 /lisp/progmodes/ruby-mode.el
parent66709725622e032f38fbd9cffbf09bb0781de90e (diff)
downloademacs-b47b98bc4b2b6f901865b7530145766a0f8da142.tar.gz
emacs-b47b98bc4b2b6f901865b7530145766a0f8da142.tar.bz2
emacs-b47b98bc4b2b6f901865b7530145766a0f8da142.zip
ruby-mode: Recognize setter symbols
* lisp/progmodes/ruby-mode.el (ruby-syntax-propertize): Add a rule for setter symbols (bug#42846). (ruby-font-lock-keywords): Remove dead code, left over from before commit 26f9c507. * lisp/progmodes/ruby-mode.el (ruby-smie--bosp): Handle '=' being part of a symbol (bug#42846). * test/lisp/progmodes/ruby-mode-resources/ruby.rb: Add corresponding indentation examples.
Diffstat (limited to 'lisp/progmodes/ruby-mode.el')
-rw-r--r--lisp/progmodes/ruby-mode.el18
1 files changed, 11 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"