GNU bug report logs -
#16182
24.3.50; ruby-mode: Indentation style of multiline literals with hanging open paren inside other parens
Previous Next
Reported by: Dmitry Gutov <dgutov <at> yandex.ru>
Date: Wed, 18 Dec 2013 03:56:02 UTC
Severity: minor
Found in version 24.3.50
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
Full log
Message #47 received at 16182 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Thursday, December 19, 2013 at 7:15 PM, Dmitry Gutov wrote:
> On 19.12.2013 14:54, Bozhidar Batsov wrote:
> > I can confirm that your method args indentation fix is working. I did,
> > however, notice the following problem after I mentioned the
> > if/unless/case with assignment indentation. Consider the following:
> >
> > res = method do |x, y|
> > something
> > end
> >
> > Might make sense to indent those like:
> >
> > res = method do |x, y|
> > something
> > end
> >
> > for consistency with the if/unless/case indentation by default.
>
> It might be more consistent, but I don't see any projects doing that.
> For example, ActiveRecord, Grape, Goliath and Rack don't.
>
> Check out the examples at the top:
>
> https://github.com/rails/rails/blob/master/activerecord/lib/active_record/base.rb
>
> https://github.com/rack/rack/blob/master/lib/rack/builder.rb
>
> It can be an option, though.
Part of the reason people are not using a particular style from time to time is simply lack of tool support. :-) I guess more people would have used that style if their editor supported it.
>
> ---
>
> Come to think of it, do you see the "align end to the keyword" style
> much? I did a grep on my gems directory, and the other style seems to be
> prevalent, especially among the non-core gems:
>
> Pry, RDoc, Minitest, Rubygems, EventMachine, Nokogiri align to keyword.
>
> ActiveRecord, ActiveSupport, other Active* gems, Cucumber, Thor, Grape,
> Excon, WebMock, Faraday align to the beginning of the statement.
>
> RSpec uses both. Yard aligns to keyword after "=", but to statement
> after "||=".
>
> Maybe we even should align to the statement by default, because, you
> know, Rails.
>
>
Well, even though I develop Rails apps for a living I wouldn’t say the style used in the Rails codebase should be considered some gold standard - after all they are outdenting “private/protected” there :-) That said - before I started using programming Ruby in Emacs I aligned to the beginning of the statement, but I stopped because this wasn’t supported in ruby-mode. After using the alignment to keyword style for several years I’ve grown to like it a lot (and it seems others are enjoying it as well http://stackoverflow.com/questions/2925028/how-do-you-assign-a-variable-with-the-result-of-a-if-else-block). I’m perfectly fine with alignment to statement becoming the default (although the change of this default would be fairly visible/disruptive, since as it stands keyword alignment is the only supported style and I guess most Rubyists using Emacs employ it).
>
> > Also:
> >
> > res =
> > method do |x, y|
> > something
> > end
> >
> > is actually indented like this:
> >
> > res =
> > method do |x, y|
> > something
> > end
> >
>
>
> Guess we can special-case this.
That’d be great.
[Message part 2 (text/html, inline)]
This bug report was last modified 11 years and 247 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.