aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2014-02-01 16:54:58 +0200
committerDmitry Gutov2014-02-01 16:54:58 +0200
commita09beb3df21677b0797e27cb75bd5c66226f6bc9 (patch)
tree305bfdfe3f0ff259d3215d1f3e40db20f6919a08
parent9ef58a52ac97a160e2818e69e7cd146e52fbdacf (diff)
downloademacs-a09beb3df21677b0797e27cb75bd5c66226f6bc9.tar.gz
emacs-a09beb3df21677b0797e27cb75bd5c66226f6bc9.zip
Fix bug#16609
* lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Check for `:' before binary operators. Don't check for `:' before `[' and `(', or their syntax status. A percent literal can't end with either.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/ruby-mode.el7
-rw-r--r--test/indent/ruby.rb7
3 files changed, 19 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 91b9aff1dba..4903bfdd1d9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12014-02-01 Dmitry Gutov <dgutov@yandex.ru>
2
3 * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Check for
4 `:' before binary operators (bug#16609). Don't check for `:'
5 before `[' and `(', or their syntax status. A percent literal
6 can't end with either.
7
12014-02-01 Lars Ingebrigtsen <larsi@gnus.org> 82014-02-01 Lars Ingebrigtsen <larsi@gnus.org>
2 9
3 * subr.el (butlast): Document what an omitted N means (bug#13437). 10 * subr.el (butlast): Document what an omitted N means (bug#13437).
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 1bce911cf0e..5cee77b29a5 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -422,14 +422,17 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'."
422 (save-excursion 422 (save-excursion
423 (skip-chars-backward " \t") 423 (skip-chars-backward " \t")
424 (not (or (bolp) 424 (not (or (bolp)
425 (memq (char-before) '(?\[ ?\())
425 (and (memq (char-before) 426 (and (memq (char-before)
426 '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\\ ?& ?> ?< ?% 427 '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\\ ?& ?> ?< ?% ?~ ?^))
427 ?~ ?^)) 428 ;; Not a binary operator symbol.
429 (not (eq (char-before (1- (point))) ?:))
428 ;; Not the end of a regexp or a percent literal. 430 ;; Not the end of a regexp or a percent literal.
429 (not (memq (car (syntax-after (1- (point)))) '(7 15)))) 431 (not (memq (car (syntax-after (1- (point)))) '(7 15))))
430 (and (eq (char-before) ?\?) 432 (and (eq (char-before) ?\?)
431 (equal (save-excursion (ruby-smie--backward-token)) "?")) 433 (equal (save-excursion (ruby-smie--backward-token)) "?"))
432 (and (eq (char-before) ?=) 434 (and (eq (char-before) ?=)
435 ;; Not a symbol :==, :!=, or a foo= method.
433 (string-match "\\`\\s." (save-excursion 436 (string-match "\\`\\s." (save-excursion
434 (ruby-smie--backward-token)))) 437 (ruby-smie--backward-token))))
435 (and (eq (char-before) ?|) 438 (and (eq (char-before) ?|)
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb
index 49ed92f8fdc..cf6bcba8c39 100644
--- a/test/indent/ruby.rb
+++ b/test/indent/ruby.rb
@@ -135,6 +135,13 @@ end
135# Bug#15208 135# Bug#15208
136if something == :== 136if something == :==
137 do_something 137 do_something
138
139 return false unless method == :+
140 x = y + z # Bug#16609
141
142 a = 1 ? 2 :(
143 2 + 3
144 )
138end 145end
139 146
140# Example from http://www.ruby-doc.org/docs/ProgrammingRuby/html/language.html 147# Example from http://www.ruby-doc.org/docs/ProgrammingRuby/html/language.html