jashkenas/coffee-script — pull request #3263 by xixixao (2013-11-27 05:28:46+00:00)
Title: Implement #1495,  Method call chaining

Implements #1495 and parts of its sibling issues.

@jashkenas was against this [3 years ago](https://github.com/jashkenas/coffee-script/issues/944#issuecomment-620690) saying:
> This has come up before, and I'm still of the opinion that it's an abuse of indentation. Leading dot accessors should attach to the final value of the previous line, and not cause the previous line to be implicitly wrapped in parentheses.

This sounds reasonable, but in practice I was unable to find any occurrences of the pattern
```coffee
a b
.c() #a(b.c())
```
vs hundreds of cases of
```coffee
a.b(c)
.d(e)
```
This has also been highly requested and discussed syntax. There have been many proposals, a lot of them dealing with indentation. I think that we can agree that the change should be as simple and useful as possible.

There are several examples already where our code looks similar to the proposal:
```coffee
a b,
c
.something() # a(b, c).something()

a
b: c
.something() # a(b: c).something()

a ->
b c
.something() # a(function () {return b(c);}).something()
```
This PR brings normal argument list on par with these, and also solves cases of nested calls and inline functions. This is now valid:
```coffee
result = range 1, 3
.concat range 4, 6
.map (x) -> x * x
.filter (x) -> x % 2 is 0

console.log result # [4, 16, 36]
```
Yet the syntax is indentation agnostic. The rule is simply that a dot accessor on a new line closes all implicit calls, or that it "attaches to the outermost preceding value".

oldschool P.S.:
```coffee
$ 'body'
.click (e) ->
$ '.box'
.fadeIn 'fast'
.addClass '.active'
.css 'marginRight', '10px'