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

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

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


From: jaseemabid
Subject: Re: bug#8576: 23.2; js-mode doesn't support multi-line variable declarations
Date: Thu, 5 Jul 2012 07:53:30 -0700 (PDT)
User-agent: G2/1.0

On Friday, 1 June 2012 13:00:21 UTC+5:30, Felix H. Dahlke  wrote:
> Okay, I've prepared a patch for this, based on Dimitriv's work. 
> I've
>     been using this for a while now and haven't run into any problems.
> 
>     
> 
>     The attached patch is against the latest revision in the emacs-23
>     branch. I can provide a patch for emacs-24 or trunk if that's
>     desirable.
> 
>     
> 
>     Here's the patched version if you'd like to try it out:
> 
>     
>     <a href="https://gist.github.com/2849799"; 
> target="_blank">https://gist.github.com/<WBR>2849799</a>
> 
>     
> 
>     And here&#39;s one that should work in Emacs 24:
> 
>     
>     <a href="https://gist.github.com/2849595"; 
> target="_blank">https://gist.github.com/<WBR>2849595</a>
> 
>     
> 
>     There&#39;s still one thing that I&#39;d like to behave differently, but I
>     thought I&#39;d best discuss this first.
> 
>     
> 
>     The patched js.el will indent the following code like this:
> 
>     
> 
>     var foo = 5,
> 
>           bar = function() {
> 
>           };
> 
>     
> 
>     That&#39;s fine. But if a function or an object literal come first, it
>     indents it like this:
> 
>     
> 
>     var bar = function() {
> 
>     },
> 
>         foo = 5;
> 
>     
> 
>     Which I consider somewhat ugly. I&#39;d like to make it indent as
>     follows:
> 
>     
> 
>     var bar = function() {
> 
>         },
> 
>         foo = 5;
> 
>     
> 
>     That should only happen for multi var declarations, single
>     declarations should indent just like before:
> 
>     
> 
>     var bar = function() {
> 
>     };
> 
>     
> 
>     Would that be acceptable? It&#39;ll make the code a bit more
>     complicated, but I think it&#39;s worth it.
> 
>     

When the first var is staring with an offset, like inside a nested function or 
something, this is failing. It feels like the second line is indented wrt to 
coloumn 0 and not wrt to the "var" statement.

This is what I expect

\t  \t  var a = "foo",
\t  \t  \t  b = "bar";


but it becomes 

\t  \t  var a = "foo",
\t  ..b = "bar";


I might be wrong, Im a noob with emacs. Reporting the behavior because the 
issue is bugging me a lot. I tried with the gist for v24 on v24.1.1.


reply via email to

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