diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2016-03-12 00:18:42 +0200 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2016-03-12 00:18:42 +0200 |
commit | 576e09e150bceb371b22c4bb26d12991737f689d (patch) | |
tree | 7eaee9394a643c00acb2a509d5c717e6c4a81b65 /lisp/progmodes/ruby-mode.el | |
parent | facb5e20ce186e47506860bde982e35020fedce5 (diff) | |
download | emacs-576e09e150bceb371b22c4bb26d12991737f689d.tar.gz |
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.
Diffstat (limited to 'lisp/progmodes/ruby-mode.el')
-rw-r--r-- | lisp/progmodes/ruby-mode.el | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index be8f96dcfd9..36c1aed529e 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 () |