emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious c


From: Dmitry Gutov
Subject: Re: [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious change, add more failing examples.
Date: Tue, 08 Oct 2013 02:05:03 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> +z = {
>> +  foo: {
>> +    a: "aaa",
>> +    b: "bbb"
>> +  }
>> +}
>
> I think I've fixed this one, now.

Thanks.

>
>> +foo +
>> +  bar
>
> This one makes no sense to me: as an instruction, it seems non-sensical
> (I assume addition is pure),

Not necessarily. Ruby has operator overloading:

irb(main):014:0> class C
irb(main):015:1> def +(other)
irb(main):016:2> puts "cowabunga!"
irb(main):017:2> end
irb(main):018:1> end
=> nil
irb(main):019:0> C.new + 3
cowabunga!
=> nil

(And there are such binary operators as << and >>, they are exprected to
modify the receiver).

Second, every statement in Ruby is an expression, and a function
implicitly returns its last expression. So a fuller example would be:

def five_times(bar)
  bar + bar + bar + bar +
    bar
end

This isn't indented right either.

> and this indentation seems incompatible
> with the previous examples like
>
>   foo = x +
>         y

Hopefully, it can be resolved in some way. I agree that

foo = x +
        y

looks kinda ugly.

But FWIW, in open source code I see "hanging" expressions more often
outside of assignments than in them.

>> +foo if

>> +  bar
>
> This is another case where implicit-semi-p needs to be refined.

I'm not sure I'm doing it right.

I've tried adding

 (and (eq (car (syntax-after (1- (point)))) 2)
      (equal (save-excursion (ruby-smie--backward-token))
             "iuwu-mod"))
             
as a new case in ruby-smie--implicit-semi-p, but it doesn't seem to
have the desired (or any) effect.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]