From: Dmitry Gutov Date: Tue, 3 Sep 2013 00:29:10 +0000 (+0300) Subject: * lisp/progmodes/ruby-mode.el (ruby-calculate-indent): Consider X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1686^2~12 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=88527bc0a26e385376c9da884feb9fe0d4d18429;p=emacs.git * lisp/progmodes/ruby-mode.el (ruby-calculate-indent): Consider two-character operators and whether the character preceding them changes their meaning. Fixes: debbugs:15208 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ad23012e749..49c6caeceb7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-09-03 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-calculate-indent): Consider + two-character operators and whether the character preceding them + changes their meaning (Bug#15208). + 2013-09-02 Fabián Ezequiel Gallina Format code sent to Python shell for robustness. diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 7ecd207f4dc..acc7738ae5c 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -137,6 +137,7 @@ This should only be called after matching against `ruby-here-doc-beg-re'." (defconst ruby-symbol-chars "a-zA-Z0-9_" "List of characters that symbol names may contain.") + (defconst ruby-symbol-re (concat "[" ruby-symbol-chars "]") "Regexp to match symbols.") @@ -935,6 +936,10 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'." (not (looking-at "[a-z_]")))) (and (looking-at ruby-operator-re) (not (ruby-special-char-p)) + (save-excursion + (forward-char -1) + (or (not (looking-at ruby-operator-re)) + (not (eq (char-before) ?:)))) ;; Operator at the end of line. (let ((c (char-after (point)))) (and diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 853f4dbf992..af1bbb9d8ab 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb @@ -66,3 +66,8 @@ end Given /toto/ do print "hello" end + +# Bug#15208 +if something == :== + do_something +end