GNU bug report logs - #9151
js-mode indentation doesn't recognize brace-less function expressions

Previous Next

Package: emacs;

Reported by: Štěpán Němec <stepnem <at> gmail.com>

Date: Fri, 22 Jul 2011 19:34:02 UTC

Severity: normal

To reply to this bug, email your comments to 9151 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9151; Package emacs. (Fri, 22 Jul 2011 19:34:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Štěpán Němec <stepnem <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 22 Jul 2011 19:34:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Štěpán Němec <stepnem <at> gmail.com>
To: bug-gnu-emacs <bug-gnu-emacs <at> gnu.org>
Subject: js-mode indentation doesn't recognize brace-less function expressions
Date: Fri, 22 Jul 2011 21:28:45 +0200
GNU Emacs 24.0.50.6 (i686-pc-linux-gnu) of 2011-01-15 on headley

In JavaScript, the following is a valid function definition:

function foo ()
    a.somewhat().complicated()
    .computation()

but `js-mode' currently indents it like this:

function foo ()
a.somewhat().complicated()
    .computation()

-- 
Štěpán




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9151; Package emacs. (Wed, 21 Aug 2019 16:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 9151 <at> debbugs.gnu.org (full text, mbox):

From: Knut Olav Bøhmer <bohmer <at> gmail.com>
To: 9151 <at> debbugs.gnu.org
Subject: bug#9151: js-mode indentation doesn't recognize brace-less function
 expressions
Date: Wed, 21 Aug 2019 09:54:18 +0200
[Message part 1 (text/plain, inline)]
This bug is probably more important to day then 8 years ago because of the
widely used  arrow function with concise body syntax as documented here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#Function_body

Right:
const something = () =>
      indent_like_this();

Wrong:
const something = () =>
not_indent_like_this();

-- 
Knut Olav Bøhmer
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9151; Package emacs. (Mon, 03 Jun 2024 19:49:01 GMT) Full text and rfc822 format available.

Message #11 received at 9151 <at> debbugs.gnu.org (full text, mbox):

From: Jakub Ječmínek <kuba <at> kubajecminek.cz>
To: Knut Olav Bøhmer <bohmer <at> gmail.com>
Cc: 9151 <at> debbugs.gnu.org
Subject: Re: bug#9151: js-mode indentation doesn't recognize brace-less
 function expressions
Date: Mon, 03 Jun 2024 19:48:01 +0000
Knut Olav Bøhmer <bohmer <at> gmail.com> writes:

> Right:
> const something = () =>
>       indent_like_this();
>
> Wrong:
> const something = () =>
> not_indent_like_this();

This indents correctly for me.


Štěpán Němec <stepnem <at> gmail.com> writes:

> In JavaScript, the following is a valid function definition:
>
> function foo ()
>     a.somewhat().complicated()
>     .computation()
>
> but `js-mode' currently indents it like this:
>
> function foo ()
> a.somewhat().complicated()
>     .computation()

I know virtually nothing about JavaScript but your example function
doesn't seem valid.  If you add curly braces and set `js-chain-indent'
to t then it works fine.





This bug report was last modified 1 year and 8 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.