Skip to content

Indent based continuations. #221

@zmthy

Description

@zmthy

At the moment a line that could appear on a previous line and definitely couldn't exist on a new line is assumed to be a continuation of the line above. For instance:
variable
.property
is interpreted as
variable.property
This is great, it makes sense and reads well. These continuations will generally be written at the same or greater level of indentation than the preceding line, though - it doesn't look quite right to write
variable
.property
As such, I would like to propose that continuations indented at levels lower than the previous line move up to a continuation of the line at their current level of indentation. Say you were setting up a Node server:
http.createServer (req, res) ->
...
res.close()
.listen 8000
would compile to
(http.createServer(function (req, res) {
...
res.close();
})).listen(8000);
It saves the awkwardness of having to wrap the expression in parentheses or saving it as a variable and referencing it again. It would also be useful for chains that involve a lot of callbacks:
$(document)
.keydown (evt) ->
...
.keyup (evt) ->
...
What do you think?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions