[Top][All Lists]

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

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

From: Felix H. Dahlke
Subject: bug#8576: 23.2; js-mode doesn't support multi-line variable declarations
Date: Tue, 17 Jul 2012 10:24:50 +0200
User-agent: Internet Messaging Program (IMP) 4.3.3

Quoting Stefan Monnier <address@hidden>:

Thank you for your efforts trying to find a good fix for this problem.
I'd like to install your changes (or some future version of them once
the wrinkles are worked out), but it's sufficiently non-trivial that
we need you to sign some copyright paperwork.

I already sent a signed CA to the FSF, it should arrive shortly.

const a = 5,
    b = 6;

Yup, that'd be a bug.

Depends, IMO. Do we want to indent on the column, or by the configured indentation level? I personally want to indent on column, so that would indeed be a problem for me (never noticed because I use a tab size of 4 and no const keyword). Should this be configurable?

If we don't make it configurable, I'd vote for going with Dmitry's variant, as that seems to be the more popular style.

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.

Thanks for the hints Dmitry and Stefan, as you undoubtly noticed, I am quite new to Emacs development, but willing to learn :)

But I'd rather get this patch in in the simple form first, and enhance the behaviour with another one.

Attachment: pgp6U2_FgDqU0.pgp
Description: PGP Digital Signature

reply via email to

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