From: Dmitry Gutov Date: Sun, 23 Feb 2014 08:26:40 +0000 (+0200) Subject: * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Handle the X-Git-Tag: emacs-24.3.90~173^2^2~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dfdb365c4ce062e3506d350e185bc71c0bcc8b10;p=emacs.git * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Handle the inconsistent second element of the list returned by `smie-indent--parent'. (ruby-font-lock-keywords): Disqualify any identifier before `=' as method call. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bcb09e177c6..40f5d7defc1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -2,6 +2,10 @@ * progmodes/ruby-mode.el (ruby-smie-rules): Don't indent specially after `=>' (bug#16811). + (ruby-smie-rules): Handle the inconsistent second element of the + list returned by `smie-indent--parent'. + (ruby-font-lock-keywords): Disqualify any identifier before `=' as + method call. 2014-02-23 Juanma Barranquero diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 709bc67451d..5cd054a22a8 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -630,9 +630,11 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." (save-excursion ;; Traverse up the parents until the parent is "." at ;; indentation, or any other token. - (while (and (progn - (goto-char (1- (cadr (smie-indent--parent)))) - (not (ruby-smie--bosp))) + (while (and (let ((parent (smie-indent--parent))) + (goto-char (cadr parent)) + (save-excursion + (unless (integerp (car parent)) (forward-char -1)) + (not (ruby-smie--bosp)))) (progn (setq smie--parent nil) (smie-rule-parent-p ".")))) @@ -2061,7 +2063,7 @@ See `font-lock-syntax-table'.") "refine" "using") 'symbols)) - (1 (unless (looking-at " *\\(?:[]|,.)}]\\|$\\)") + (1 (unless (looking-at " *\\(?:[]|,.)}=]\\|$\\)") font-lock-builtin-face))) ;; Kernel methods that have no required arguments. (,(concat diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 5fd59bfb186..344f16b3d13 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb @@ -357,6 +357,13 @@ zoo .lose( q, p) +a.records().map(&:b).zip( + foo) + +# FIXME: This is not consistent with the example below it, but this +# ofset only happens if the colon is at eol, which wouldn't be often. +# Tokenizing `bar:' as `:bar =>' would be better, but it's hard to +# distinguish from a variable reference inside a ternary operator. foo(bar: tee)