all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 8576@debbugs.gnu.org, fhd@ubercode.de
Subject: bug#8576: 23.2; js-mode doesn't support multi-line variable declarations
Date: Tue, 17 Jul 2012 02:32:40 -0400	[thread overview]
Message-ID: <jwvd33uc3g7.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <5004F15E.9040101@yandex.ru> (Dmitry Gutov's message of "Tue, 17 Jul 2012 09:00:14 +0400")

> const a = 5,
>     b = 6;

Yup, that'd be a bug.

>>>> 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.
>>> I don't think this will be much of a problem.
>> Probably not, but I fear it's going to be a lot of work - at least
>> when I do it.
> I meant that nobody will care, most likely. But the implementation
> shouldn't be too hard either - add a function to `post-command-hook'
> which would check if the command is `self-insert-command', check if we
> inserted a comma, skip backward to the previous non-whitespace char, see
> if it's } or ], etc.

Rather than a post-command-hook, that would be a post-self-insert-hook.
And that would need to be conditional on some js-electric-foo variable
(or better yet, be made to work with electric-indent-mode).

Note that looking forward during indentation, while occasionally
annoying, is not that big of a problem in practice: contrary to popular
belief, we don't write code quite as linearly as one might think.
We at least as frequently edit code in place.

BTW, rather than a post-self-insert-hook, you could put a special
text-property `js--indent-depends-on-next-line' on the line, and then
when indenting a line, you could check if the previous line has that
property and if so indent both lines.  I'm not claiming it's a better
approach, just an alternative one.


        Stefan





  reply	other threads:[~2012-07-17  6:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-28  7:22 bug#8576: 23.2; js-mode doesn't support multi-line variable declarations Felix H. Dahlke
2011-06-19 20:38 ` Daniel Colascione
2012-02-15 12:32   ` Felix H. Dahlke
2012-02-15 18:58     ` Stefan Monnier
2012-02-15 19:04       ` Glenn Morris
2012-02-15 19:25       ` Daniel Colascione
2012-02-15 20:41         ` Stefan Monnier
2012-04-04 11:26         ` Felix H. Dahlke
2012-06-01  7:30           ` Felix H. Dahlke
     [not found]           ` <mailman.2065.1338535901.855.bug-gnu-emacs@gnu.org>
2012-07-05 14:53             ` jaseemabid
2012-02-24  2:16 ` Dmitry Gutov
2012-03-03  1:46 ` bug#8576: " Zeth
2012-03-03  4:51   ` Daniel Colascione
2012-06-07 23:04 ` bug#8576: 23.2; " Dmitry Gutov
2012-06-08  3:13   ` Felix H. Dahlke
2012-07-17  3:16   ` Felix H. Dahlke
2012-07-05 23:02 ` bug#8576: 23.2; , " Dmitry Gutov
2012-07-06  0:52 ` Dmitry Gutov
     [not found] ` <mailman.4157.1341536766.855.bug-gnu-emacs@gnu.org>
2012-07-06  1:23   ` jaseemabid
2012-07-17  4:21 ` bug#8576: 23.2; " Dmitry Gutov
2012-07-17  4:37   ` Felix H. Dahlke
2012-07-17  5:00 ` Dmitry Gutov
2012-07-17  6:32   ` Stefan Monnier [this message]
2012-07-17  8:24     ` Felix H. Dahlke
2012-07-17  9:50       ` Stefan Monnier
2012-07-17  9:51         ` Felix H. Dahlke
2012-07-17 17:33         ` Felix H. Dahlke
2013-01-10  3:48           ` Felix H. Dahlke
2013-01-11 23:25             ` Stefan Monnier
2013-01-12  2:59               ` Felix H. Dahlke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvd33uc3g7.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=8576@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=fhd@ubercode.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.