emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b47b98b: ruby-mode: Recognize setter symbols


From: Dmitry Gutov
Subject: master b47b98b: ruby-mode: Recognize setter symbols
Date: Thu, 31 Dec 2020 11:40:11 -0500 (EST)

branch: master
commit b47b98bc4b2b6f901865b7530145766a0f8da142
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    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.
---
 lisp/progmodes/ruby-mode.el                     | 18 +++++++++++-------
 test/lisp/progmodes/ruby-mode-resources/ruby.rb |  8 ++++++++
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 45b0f84..7d72a78 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 9592803..434237c 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]