bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#8576: 23.2; js-mode doesn't support multi-line variable declarations


From: Felix H. Dahlke
Subject: bug#8576: 23.2; js-mode doesn't support multi-line variable declarations
Date: Tue, 17 Jul 2012 05:16:23 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

I tried some things but couldn't really make it work like I wanted. So I
decided to just improve the patch a bit. I am now using the proper
indentation which also fixes the issue reported by jaseemabid.

I've attached the patch for Emacs 24 and updated the Gists:
https://gist.github.com/2849595 (Emacs 24)
https://gist.github.com/2849799 (Emacs 23)

The problem with my desired behaviour is indeed that it requires forward
parsing. So when you're indenting a full statement like this, it works:

var x = {
        num: 5
    },
    y = 6;

However, when you're initially typing this (pressing TAB on each line),
it ends up like this:

var x = {
    num: 5
},
    y = 6;

You'd have to go back and indent the whole thing again after adding the
closing brace followed by a comma. That's actually pretty annoying in
practice and would probably lead to highly inconsistent indendation, so
I decided to leave it out for now.

The only solution I can think of would be to go back up after typing a
closing brace followed by a comma and indent the preceeding lines. Some
modes do that, but it would require drastic changes to js.el. I'd rather
get this patch in first and see if the issue annoys me (or anyone else)
enough to work further on this.

Attachment: indent-multi-line-var-statements.patch
Description: Text Data

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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