[Top][All Lists]

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

Re: CC Mode 5.28 (); JavaScript indentation problem

From: Robert Ginda
Subject: Re: CC Mode 5.28 (); JavaScript indentation problem
Date: Tue, 21 Aug 2001 13:17:44 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2+) Gecko/20010731

Martin Stjernholm wrote:
rginda@netscape.com (Robert Ginda) wrote:
1: Foo.prototype.doFoo =
2: function foo()
3: {
4:     if (this.bar)
5:     this.baz();  // XXX This line is indented incorrectly
6: }

This looks pretty much like the lambda construct in Pike. Try to set
c-lambda-key to something that matches the "function" token and it
might work better.

That seems to have done the trick, thanks for the suggestion!

(If there are only small issues like this, it'd be simple to add
support for javascript. The big problem is that linebreaks are
relevant in some cases if I'm not mistaken, and those are consistently
ignored by all the recognition code.)

There are some edge cases where line breaks interact with "automatic semicolon insertion" in a way that makes them significant. But if you're not ending each statement with a semicolon you'll confuse cc-mode anyway, something I've come to regard as a feature.

Slightly off the original topic, cc-mode also has issues with if statements at the top level, such as...

1: if (1)        //topmost-intro
2:    f();       //func-decl-cont
3: else          //topmost-intro
4: g();          //topmost-intro-cont


1: function q()  //topmost-intro
2: {             //inline-open
3:     if (1)    //defun-block-intro
4:         f();  //substatement
5:     else      //else-clause
6:         g();  //substatement
7: }

These aren't all that common in my code, so it's easy to fix them up by hand. Some of the keywords are wrong as well, but modulo these issues cc-mode is quite capable of indenting the kind of JavaScript I write.


reply via email to

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