all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious change, add more failing examples.
       [not found] <E1VTAqX-0005m7-J3@vcs.savannah.gnu.org>
@ 2013-10-07 16:55 ` Stefan Monnier
  2013-10-07 23:05   ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-10-07 16:55 UTC (permalink / raw
  To: Dmitry Gutov; +Cc: emacs-devel

> +z = {
> +  foo: {
> +    a: "aaa",
> +    b: "bbb"
> +  }
> +}

I think I've fixed this one, now.

> +foo +
> +  bar

This one makes no sense to me: as an instruction, it seems non-sensical
(I assume addition is pure), and this indentation seems incompatible
with the previous examples like

  foo = x +
        y

> +foo if
> +  bar

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


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious change, add more failing examples.
  2013-10-07 16:55 ` [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious change, add more failing examples Stefan Monnier
@ 2013-10-07 23:05   ` Dmitry Gutov
  2013-10-08  3:37     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2013-10-07 23:05 UTC (permalink / raw
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> 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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious change, add more failing examples.
  2013-10-07 23:05   ` Dmitry Gutov
@ 2013-10-08  3:37     ` Stefan Monnier
  2013-10-09  3:27       ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-10-08  3:37 UTC (permalink / raw
  To: Dmitry Gutov; +Cc: emacs-devel

>> 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.

When you're right after the newline that follows the "if" and you call
ruby-smie--backward-token do you then get ";" (and move to right after
the "if") or do you get "iuwu-mod" (and move to right before the "if")?

BTW, I don't guarantee that fixing ruby-smie--implicit-semi-p for this
case will give you the intended effect, but without it it'll be
difficult to get the intended effect: as it stands, SMIE considers the
newline after "if" to terminate the instruction, so the next instruction
is of course aligned with the previous one, and changing that in the
smie-rules part would invariably break other indentation cases.


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious change, add more failing examples.
  2013-10-08  3:37     ` Stefan Monnier
@ 2013-10-09  3:27       ` Dmitry Gutov
  2013-10-09 12:47         ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2013-10-09  3:27 UTC (permalink / raw
  To: Stefan Monnier; +Cc: emacs-devel

On 08.10.2013 06:37, Stefan Monnier wrote:
> When you're right after the newline that follows the "if" and you call
> ruby-smie--backward-token do you then get ";" (and move to right after
> the "if") or do you get "iuwu-mod" (and move to right before the "if")?

The latter.

> BTW, I don't guarantee that fixing ruby-smie--implicit-semi-p for this
> case will give you the intended effect, but without it it'll be
> difficult to get the intended effect: as it stands, SMIE considers the
> newline after "if" to terminate the instruction, so the next instruction
> is of course aligned with the previous one, and changing that in the
> smie-rules part would invariably break other indentation cases.

Thanks, I think I've fixed that with the change to ruby-smie-rules in 
114587.

By the way, could you explain what does the `when' predicate in (:before 
. "do") rule in ruby-smie-rules do?

If I remove the `when' and just leave (smie-rule-parent), none of the 
indentation examples break, AFAICS.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious change, add more failing examples.
  2013-10-09  3:27       ` Dmitry Gutov
@ 2013-10-09 12:47         ` Stefan Monnier
  2013-10-09 13:40           ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-10-09 12:47 UTC (permalink / raw
  To: Dmitry Gutov; +Cc: emacs-devel

> If I remove the `when' and just leave (smie-rule-parent), none of the
> indentation examples break, AFAICS.

IIRC it's for the case where the "do" is at the beginning of the line or
is not at the end of the line.

I guess under Ruby both of these are rare.


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious change, add more failing examples.
  2013-10-09 12:47         ` Stefan Monnier
@ 2013-10-09 13:40           ` Dmitry Gutov
  2013-10-09 18:24             ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2013-10-09 13:40 UTC (permalink / raw
  To: Stefan Monnier; +Cc: emacs-devel

On 09.10.2013 15:47, Stefan Monnier wrote:
>> If I remove the `when' and just leave (smie-rule-parent), none of the
>> indentation examples break, AFAICS.
>
> IIRC it's for the case where the "do" is at the beginning of the line

That would be a syntax error.

> or is not at the end of the line.

I found an example where it makes a difference, but it looks too weird:

     it do foo {

          }
        end

Never seen Ruby code written this way. I'm going to simplify that case, 
then, as long as you don't mind.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious change, add more failing examples.
  2013-10-09 13:40           ` Dmitry Gutov
@ 2013-10-09 18:24             ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2013-10-09 18:24 UTC (permalink / raw
  To: Dmitry Gutov; +Cc: emacs-devel

>>> If I remove the `when' and just leave (smie-rule-parent), none of the
>>> indentation examples break, AFAICS.
>> IIRC it's for the case where the "do" is at the beginning of the line
> That would be a syntax error.

Not if the previous lines ends with \ if I understand correctly.

> Never seen Ruby code written this way. I'm going to simplify that case,
> then, as long as you don't mind.

Be my guest.  I never wrote a single line of Ruby and have not seen much
more Ruby code than what's in the ruby.rb file, so don't follow my lead.


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-10-09 18:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E1VTAqX-0005m7-J3@vcs.savannah.gnu.org>
2013-10-07 16:55 ` [Emacs-diffs] trunk r114556: * test/indent/ruby.rb: Fix a spurious change, add more failing examples Stefan Monnier
2013-10-07 23:05   ` Dmitry Gutov
2013-10-08  3:37     ` Stefan Monnier
2013-10-09  3:27       ` Dmitry Gutov
2013-10-09 12:47         ` Stefan Monnier
2013-10-09 13:40           ` Dmitry Gutov
2013-10-09 18:24             ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.