GNU bug report logs - #5586
23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)

Previous Next

Package: emacs;

Reported by: Paul Pogonyshev <pogonyshev <at> gmx.net>

Date: Tue, 16 Feb 2010 22:34:02 UTC

Severity: wishlist

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5586 in the body.
You can then email your comments to 5586 AT debbugs.gnu.org in the normal way.

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#5586; Package emacs. (Tue, 16 Feb 2010 22:34:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Pogonyshev <pogonyshev <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 16 Feb 2010 22:34:02 GMT) Full text and rfc822 format available.

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

From: Paul Pogonyshev <pogonyshev <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1.92.1;
	Electric indentation and hungry backspace deletion in JavaScript mode
	(js-mode)
Date: Wed, 17 Feb 2010 00:31:45 +0200
Package: emacs
Severity: wishlist

JavaScript is quite similar in syntax to C-like languages (Java, C++
etc.), so it's natural to use the same editing techniques for it.  It
would be nice if Emacs gave JS mode a more "familiar" feel.

For me, the most wanted features are electric indentation and hungry
backspace.  I.e. when typing '{', '(' or a similar control character
the current line would be automatically reindented.  And backspace
would delete all space characters to the left of the point, not just
one.

Paul





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5586; Package emacs. (Fri, 26 Mar 2010 06:16:01 GMT) Full text and rfc822 format available.

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

From: Daniel Colascione <dan.colascione <at> gmail.com>
To: Paul Pogonyshev <pogonyshev <at> gmx.net>
Cc: 5586 <at> debbugs.gnu.org
Subject: Re: bug#5586: 23.1.92.1; Electric indentation and hungry backspace
	deletion in JavaScript mode (js-mode)
Date: Fri, 26 Mar 2010 01:03:00 -0400
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2/16/10 5:31 PM, Paul Pogonyshev wrote:
> Package: emacs
> Severity: wishlist
> 
> JavaScript is quite similar in syntax to C-like languages (Java, C++
> etc.), so it's natural to use the same editing techniques for it.  It
> would be nice if Emacs gave JS mode a more "familiar" feel.
> 
> For me, the most wanted features are electric indentation and hungry
> backspace.  I.e. when typing '{', '(' or a similar control character
> the current line would be automatically reindented.  And backspace
> would delete all space characters to the left of the point, not just
> one.
> 
> Paul

espresso-mode actually had electric indentation when I submitted it for
inclusion in Emacs. Can we restore that functionality?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEYEARECAAYFAkusQAQACgkQ17c2LVA10VsA1ACeMwZPtnZnw3aEm3B6/sb+8A5T
hhAAnjM99lr4a5arx69ehVxBM/sv9n6P
=trl7
-----END PGP SIGNATURE-----




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5586; Package emacs. (Sun, 28 Mar 2010 20:47:02 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Daniel Colascione <dan.colascione <at> gmail.com>
Cc: 5586 <at> debbugs.gnu.org, Paul Pogonyshev <pogonyshev <at> gmx.net>
Subject: Re: bug#5586: 23.1.92.1;
	Electric indentation and hungry backspace deletion in JavaScript mode
	(js-mode)
Date: Sun, 28 Mar 2010 16:46:45 -0400
> espresso-mode actually had electric indentation when I submitted it
> for inclusion in Emacs. Can we restore that functionality?

You're right, it was a mistake to take that out, since CC mode also has
electric punctuation.

I am still not happy about the way it's implemented in either mode---I
think Emacs needs some kind of centralized mechanism for this---but that
is a longer-term project.  In the meantime, I've restored the deleted
code in the branch.

One difference, however, is that espresso-mode did electric punctuation
for `+-.'.  I didn't restore this yet, since CC mode does not do
electric punctuation for these characters.  Is there any reason we need
to do this specially for Javascript?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5586; Package emacs. (Sun, 28 Mar 2010 20:59:01 GMT) Full text and rfc822 format available.

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

From: Daniel Colascione <dan.colascione <at> gmail.com>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: 5586 <at> debbugs.gnu.org, Paul Pogonyshev <pogonyshev <at> gmx.net>
Subject: Re: bug#5586: 23.1.92.1; Electric indentation and hungry backspace
	deletion in JavaScript mode (js-mode)
Date: Sun, 28 Mar 2010 16:58:49 -0400
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/28/10 4:46 PM, Chong Yidong wrote:
> I am still not happy about the way it's implemented in either mode---I
> think Emacs needs some kind of centralized mechanism for this---but that
> is a longer-term project.  

The chief difficulty I see is that in some modes, indentation isn't
idempotent: if you ran indent-line-function from some generic electric
code, it might change the indentation of the current line in unwanted
ways. (Imagine python-mode, where indent-line-function cycles through
feasible indentation levels for a given line.)

At best, modes would have to opt-in, and if each mode needs some glue
anyway, why not just let each mode handle electric characters itself?

> In the meantime, I've restored the deleted
> code in the branch.

Thanks.

> One difference, however, is that espresso-mode did electric punctuation
> for `+-.'.  I didn't restore this yet, since CC mode does not do
> electric punctuation for these characters.  Is there any reason we need
> to do this specially for Javascript?

There's no particular reason, no. The cc-mode set of electric characters
is probably fine.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEYEARECAAYFAkuvwwkACgkQ17c2LVA10VtXIACgmgSYoR4WMmxkOF4l7QoEATYQ
b8oAoNwNRjoQvMSkmd6gWIyNy/8IZBnW
=8XTU
-----END PGP SIGNATURE-----




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5586; Package emacs. (Sun, 28 Mar 2010 21:00:03 GMT) Full text and rfc822 format available.

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

From: Daniel Colascione <dan.colascione <at> gmail.com>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: 5586 <at> debbugs.gnu.org, Paul Pogonyshev <pogonyshev <at> gmx.net>
Subject: Re: bug#5586: 23.1.92.1; Electric indentation and hungry backspace
	deletion in JavaScript mode (js-mode)
Date: Sun, 28 Mar 2010 16:59:14 -0400
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/28/10 4:46 PM, Chong Yidong wrote:
> I am still not happy about the way it's implemented in either mode---I
> think Emacs needs some kind of centralized mechanism for this---but that
> is a longer-term project.  

The chief difficulty I see is that in some modes, indentation isn't
idempotent: if you ran indent-line-function from some generic electric
code, it might change the indentation of the current line in unwanted
ways. (Imagine python-mode, where indent-line-function cycles through
feasible indentation levels for a given line.)

At best, modes would have to opt-in, and if each mode needs some glue
anyway, why not just let each mode handle electric characters itself?

> In the meantime, I've restored the deleted
> code in the branch.

Thanks.

> One difference, however, is that espresso-mode did electric punctuation
> for `+-.'.  I didn't restore this yet, since CC mode does not do
> electric punctuation for these characters.  Is there any reason we need
> to do this specially for Javascript?

There's no particular reason, no. The cc-mode set of electric characters
is probably fine.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEYEARECAAYFAkuvwyIACgkQ17c2LVA10VtH3gCeOCAeJGGzWDM1NATJ5HzOakbJ
Ix8Ani2twtZPGkUe0G8uQs5v+w0XQmjx
=1shD
-----END PGP SIGNATURE-----




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5586; Package emacs. (Sun, 28 Mar 2010 22:38:01 GMT) Full text and rfc822 format available.

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

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Daniel Colascione <dan.colascione <at> gmail.com>
Cc: Chong Yidong <cyd <at> stupidchicken.com>, 5586 <at> debbugs.gnu.org,
	Paul Pogonyshev <pogonyshev <at> gmx.net>
Subject: Re: bug#5586: 23.1.92.1; Electric indentation and hungry backspace 
	deletion in JavaScript mode (js-mode)
Date: Mon, 29 Mar 2010 00:37:24 +0200
On Sun, Mar 28, 2010 at 10:58 PM, Daniel Colascione
<dan.colascione <at> gmail.com> wrote:
>
> The chief difficulty I see is that in some modes, indentation isn't
> idempotent: if you ran indent-line-function from some generic electric
> code, it might change the indentation of the current line in unwanted
> ways. (Imagine python-mode, where indent-line-function cycles through
> feasible indentation levels for a given line.)
>
> At best, modes would have to opt-in, and if each mode needs some glue
> anyway, why not just let each mode handle electric characters itself?


Because without something like indent-line-function you can not handle
it in a more generic way.

The absense of this in some major modes has for example costed me a
lot of burden in mumamo (the framework in nXhtml for mult major modes
in a buffer). Actually indent-line-function is not generic enough. One
more level is needed: one that computes the desirable indentation.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5586; Package emacs. (Mon, 29 Mar 2010 01:50:03 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Colascione <dan.colascione <at> gmail.com>
Cc: Chong Yidong <cyd <at> stupidchicken.com>, 5586 <at> debbugs.gnu.org,
	Paul Pogonyshev <pogonyshev <at> gmx.net>
Subject: Re: bug#5586: 23.1.92.1;
	Electric indentation and hungry backspace deletion in JavaScript mode
	(js-mode)
Date: Sun, 28 Mar 2010 21:49:40 -0400
> At best, modes would have to opt-in, and if each mode needs some glue
> anyway, why not just let each mode handle electric characters itself?

For one, it would allow users to turn it on/off globally rather than
having to do it for every mode.  Also every mode shouldn't have to
reinvent it.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5586; Package emacs. (Mon, 07 Aug 2017 00:26:02 GMT) Full text and rfc822 format available.

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

From: Tom Tromey <tom <at> tromey.com>
To: 5586 <at> debbugs.gnu.org
Subject: is this bug still valid?
Date: Sun, 06 Aug 2017 18:25:11 -0600
js.el now has:

  (setq-local electric-indent-chars
	      (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*".

... so I think the original request for electric indentation has been
met.

Maybe the FIXME should be addressed by moving "[]" (and "*" - I don't
know that this one is so useful) out of the comment and into the string?

Hungry deletion seems like something that should be done generically in
electric.el.

Tom




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5586; Package emacs. (Mon, 31 Jan 2022 17:09:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Tom Tromey <tom <at> tromey.com>
Cc: 5586 <at> debbugs.gnu.org
Subject: Re: bug#5586: 23.1.92.1; Electric indentation and hungry backspace
 deletion in JavaScript mode (js-mode)
Date: Mon, 31 Jan 2022 18:08:06 +0100
Tom Tromey <tom <at> tromey.com> writes:

> js.el now has:
>
>   (setq-local electric-indent-chars
> 	      (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*".
>
> ... so I think the original request for electric indentation has been
> met.

I guess so, so I'm closing this bug report.  (If there's more to be done
here, please respond to the debbugs address and we'll reopen.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 5586 <at> debbugs.gnu.org and Paul Pogonyshev <pogonyshev <at> gmx.net> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 31 Jan 2022 17:09:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 01 Mar 2022 12:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 56 days ago.

Previous Next


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