From: Dmitry Gutov Date: Sat, 1 Feb 2014 14:54:58 +0000 (+0200) Subject: Fix bug#16609 X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~203 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a09beb3df21677b0797e27cb75bd5c66226f6bc9;p=emacs.git 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 91b9aff1dba..4903bfdd1d9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-02-01 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Check for + `:' before binary operators (bug#16609). Don't check for `:' + before `[' and `(', or their syntax status. A percent literal + can't end with either. + 2014-02-01 Lars Ingebrigtsen * 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'." (save-excursion (skip-chars-backward " \t") (not (or (bolp) + (memq (char-before) '(?\[ ?\()) (and (memq (char-before) - '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\\ ?& ?> ?< ?% - ?~ ?^)) + '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\\ ?& ?> ?< ?% ?~ ?^)) + ;; Not a binary operator symbol. + (not (eq (char-before (1- (point))) ?:)) ;; Not the end of a regexp or a percent literal. (not (memq (car (syntax-after (1- (point)))) '(7 15)))) (and (eq (char-before) ?\?) (equal (save-excursion (ruby-smie--backward-token)) "?")) (and (eq (char-before) ?=) + ;; Not a symbol :==, :!=, or a foo= method. (string-match "\\`\\s." (save-excursion (ruby-smie--backward-token)))) (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 # Bug#15208 if something == :== do_something + + return false unless method == :+ + x = y + z # Bug#16609 + + a = 1 ? 2 :( + 2 + 3 + ) end # Example from http://www.ruby-doc.org/docs/ProgrammingRuby/html/language.html