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.
This commit is contained in:
parent
facb5e20ce
commit
576e09e150
2 changed files with 8 additions and 5 deletions
|
@ -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 ()
|
||||
|
|
|
@ -24,8 +24,8 @@ def foo
|
|||
# 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 @@ def begin
|
|||
bar
|
||||
|
||||
foo_bar_tee(1, 2, 3)
|
||||
.qux.bar
|
||||
.tee
|
||||
.qux&.bar
|
||||
.tee.bar
|
||||
&.tee
|
||||
|
||||
foo do
|
||||
bar
|
||||
|
|
Loading…
Add table
Reference in a new issue