diff options
| author | Dmitry Gutov | 2016-03-16 04:32:59 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2016-03-16 04:32:59 +0200 |
| commit | 2036be4666becf02f4524d63595e3da55b14ff0d (patch) | |
| tree | 327d28def64a3cd558d36efc55e14cb194a4be30 | |
| parent | 1d686c2afb7c6c869c339f7c70daae969b429429 (diff) | |
| download | emacs-2036be4666becf02f4524d63595e3da55b14ff0d.tar.gz emacs-2036be4666becf02f4524d63595e3da55b14ff0d.zip | |
Fix Ruby's operator precedence
* lisp/progmodes/ruby-mode.el (ruby-smie-grammar):
Rearrange the smie-precs->prec2 form.
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 11 | ||||
| -rw-r--r-- | test/indent/ruby.rb | 23 |
2 files changed, 28 insertions, 6 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index edd89b30c9f..60480d603c3 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -406,16 +406,17 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." | |||
| 406 | '((right "=") | 406 | '((right "=") |
| 407 | (right "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" | 407 | (right "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" |
| 408 | "<<=" ">>=" "&&=" "||=") | 408 | "<<=" ">>=" "&&=" "||=") |
| 409 | (left ".." "...") | 409 | (nonassoc ".." "...") |
| 410 | (left "+" "-") | ||
| 411 | (left "*" "/" "%" "**") | ||
| 412 | (left "&&" "||") | 410 | (left "&&" "||") |
| 413 | (left "^" "&" "|") | ||
| 414 | (nonassoc "<=>") | 411 | (nonassoc "<=>") |
| 415 | (nonassoc ">" ">=" "<" "<=") | ||
| 416 | (nonassoc "==" "===" "!=") | 412 | (nonassoc "==" "===" "!=") |
| 417 | (nonassoc "=~" "!~") | 413 | (nonassoc "=~" "!~") |
| 414 | (nonassoc ">" ">=" "<" "<=") | ||
| 415 | (left "^" "&" "|") | ||
| 418 | (left "<<" ">>") | 416 | (left "<<" ">>") |
| 417 | (left "+" "-") | ||
| 418 | (left "*" "/" "%") | ||
| 419 | (left "**") | ||
| 419 | (assoc ".")))))) | 420 | (assoc ".")))))) |
| 420 | 421 | ||
| 421 | (defun ruby-smie--bosp () | 422 | (defun ruby-smie--bosp () |
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 85f2708bd98..b038512b114 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb | |||
| @@ -295,10 +295,31 @@ foo > bar && | |||
| 295 | tee < qux | 295 | tee < qux |
| 296 | 296 | ||
| 297 | zux do | 297 | zux do |
| 298 | foo == bar and | 298 | foo == bar && |
| 299 | tee == qux | 299 | tee == qux |
| 300 | |||
| 301 | a = 3 and | ||
| 302 | b = 4 | ||
| 300 | end | 303 | end |
| 301 | 304 | ||
| 305 | foo + bar == | ||
| 306 | tee + qux | ||
| 307 | |||
| 308 | 1 .. 2 && | ||
| 309 | 3 | ||
| 310 | |||
| 311 | 3 < 4 + | ||
| 312 | 5 | ||
| 313 | |||
| 314 | 10 << 4 ^ | ||
| 315 | 20 | ||
| 316 | |||
| 317 | 100 + 2 >> | ||
| 318 | 3 | ||
| 319 | |||
| 320 | 2 ** 10 / | ||
| 321 | 2 | ||
| 322 | |||
| 302 | foo ^ | 323 | foo ^ |
| 303 | bar | 324 | bar |
| 304 | 325 | ||