unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9151: js-mode indentation doesn't recognize brace-less function expressions
@ 2011-07-22 19:28 Štěpán Němec
  2019-08-21  7:54 ` Knut Olav Bøhmer
  2024-06-03 19:48 ` Jakub Ječmínek via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 3+ messages in thread
From: Štěpán Němec @ 2011-07-22 19:28 UTC (permalink / raw)
  To: 9151

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





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#9151: js-mode indentation doesn't recognize brace-less function expressions
  2011-07-22 19:28 bug#9151: js-mode indentation doesn't recognize brace-less function expressions Štěpán Němec
@ 2019-08-21  7:54 ` Knut Olav Bøhmer
  2024-06-03 19:48 ` Jakub Ječmínek via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 3+ messages in thread
From: Knut Olav Bøhmer @ 2019-08-21  7:54 UTC (permalink / raw)
  To: 9151

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 704 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#9151: js-mode indentation doesn't recognize brace-less function expressions
  2011-07-22 19:28 bug#9151: js-mode indentation doesn't recognize brace-less function expressions Štěpán Němec
  2019-08-21  7:54 ` Knut Olav Bøhmer
@ 2024-06-03 19:48 ` Jakub Ječmínek via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Ječmínek via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-06-03 19:48 UTC (permalink / raw)
  To: Knut Olav Bøhmer; +Cc: 9151

Knut Olav Bøhmer <bohmer@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@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.






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-03 19:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-22 19:28 bug#9151: js-mode indentation doesn't recognize brace-less function expressions Štěpán Němec
2019-08-21  7:54 ` Knut Olav Bøhmer
2024-06-03 19:48 ` Jakub Ječmínek via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).