emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-25 576e09e: Support Ruby 2.3.0's safe navigation ope


From: Dmitry Gutov
Subject: [Emacs-diffs] emacs-25 576e09e: Support Ruby 2.3.0's safe navigation operator
Date: Fri, 11 Mar 2016 22:18:48 +0000

branch: emacs-25
commit 576e09e150bceb371b22c4bb26d12991737f689d
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Support Ruby 2.3.0's safe navigation operator
    
    * lisp/progmodes/ruby-mode.el (ruby-smie--forward-token)
    (ruby-smie--backward-token): Tokenize '&.' as '.'.
    (ruby-smie--implicit-semi-p): Check for possible '&' before '.'.
    
    * test/indent/ruby.rb: Add an example using safe navigation
    operator.  Fix a syntax error in existing example.
---
 lisp/progmodes/ruby-mode.el |    4 +++-
 test/indent/ruby.rb         |    9 +++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index be8f96d..36c1aed 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -444,7 +444,7 @@ It is used when `ruby-encoding-magic-comment-style' is set 
to `custom'."
                           '("iuwu-mod" "and" "or")))
              (save-excursion
                (forward-comment 1)
-               (eq (char-after) ?.))))))
+               (looking-at "&?\\."))))))
 
 (defun ruby-smie--redundant-do-p (&optional skip)
   (save-excursion
@@ -535,6 +535,7 @@ It is used when `ruby-encoding-magic-comment-style' is set 
to `custom'."
                  (line-end-position))
               (ruby-smie--forward-token)) ;Fully redundant.
              (t ";")))
+           ((equal tok "&.") ".")
            (t tok)))))))))
 
 (defun ruby-smie--backward-token ()
@@ -580,6 +581,7 @@ It is used when `ruby-encoding-magic-comment-style' is set 
to `custom'."
                (line-end-position))
             (ruby-smie--backward-token)) ;Fully redundant.
            (t ";")))
+         ((equal tok "&.") ".")
          (t tok)))))))
 
 (defun ruby-smie--indent-to-stmt ()
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb
index 585263d..51923f7 100644
--- a/test/indent/ruby.rb
+++ b/test/indent/ruby.rb
@@ -24,8 +24,8 @@ d = %(hello (nested) world)
 # Don't propertize percent literals inside strings.
 "(%s, %s)" % [123, 456]
 
-"abc/#{def}ghi"
-"abc\#{def}ghi"
+"abc/#{ddf}ghi"
+"abc\#{ddf}ghi"
 
 # Or inside comments.
 x = # "tot %q/to"; =
@@ -303,8 +303,9 @@ foo ^
   bar
 
 foo_bar_tee(1, 2, 3)
-  .qux.bar
-  .tee
+  .qux&.bar
+  .tee.bar
+  &.tee
 
 foo do
   bar



reply via email to

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