all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)
@ 2010-02-16 22:31 Paul Pogonyshev
  2010-03-26  5:03 ` Daniel Colascione
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Paul Pogonyshev @ 2010-02-16 22:31 UTC (permalink / raw)
  To: 5586

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







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

* bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)
  2010-02-16 22:31 bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode) Paul Pogonyshev
@ 2010-03-26  5:03 ` Daniel Colascione
  2010-03-28 20:46 ` Chong Yidong
  2017-08-07  0:25 ` bug#5586: is this bug still valid? Tom Tromey
  2 siblings, 0 replies; 10+ messages in thread
From: Daniel Colascione @ 2010-03-26  5:03 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: 5586

-----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-----






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

* bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)
  2010-02-16 22:31 bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode) Paul Pogonyshev
  2010-03-26  5:03 ` Daniel Colascione
@ 2010-03-28 20:46 ` Chong Yidong
  2010-03-28 20:58   ` Daniel Colascione
                     ` (2 more replies)
  2017-08-07  0:25 ` bug#5586: is this bug still valid? Tom Tromey
  2 siblings, 3 replies; 10+ messages in thread
From: Chong Yidong @ 2010-03-28 20:46 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: 5586, Paul Pogonyshev

> 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?






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

* bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)
  2010-03-28 20:46 ` Chong Yidong
@ 2010-03-28 20:58   ` Daniel Colascione
  2010-03-28 22:37     ` Lennart Borgman
  2010-03-29  1:49     ` Stefan Monnier
  2010-03-28 20:59   ` Daniel Colascione
  2010-03-29  1:47   ` Electricity (was: bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)) Stefan Monnier
  2 siblings, 2 replies; 10+ messages in thread
From: Daniel Colascione @ 2010-03-28 20:58 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 5586, Paul Pogonyshev

-----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-----






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

* bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)
  2010-03-28 20:46 ` Chong Yidong
  2010-03-28 20:58   ` Daniel Colascione
@ 2010-03-28 20:59   ` Daniel Colascione
  2010-03-29  1:47   ` Electricity (was: bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)) Stefan Monnier
  2 siblings, 0 replies; 10+ messages in thread
From: Daniel Colascione @ 2010-03-28 20:59 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 5586, Paul Pogonyshev

-----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-----






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

* bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)
  2010-03-28 20:58   ` Daniel Colascione
@ 2010-03-28 22:37     ` Lennart Borgman
  2010-03-29  1:49     ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Lennart Borgman @ 2010-03-28 22:37 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: Chong Yidong, 5586, Paul Pogonyshev

On Sun, Mar 28, 2010 at 10:58 PM, Daniel Colascione
<dan.colascione@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.






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

* Electricity (was: bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode))
  2010-03-28 20:46 ` Chong Yidong
  2010-03-28 20:58   ` Daniel Colascione
  2010-03-28 20:59   ` Daniel Colascione
@ 2010-03-29  1:47   ` Stefan Monnier
  2 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2010-03-29  1:47 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

> 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.

Agreed.  If someone could try to survey the different kinds of
"electricity" we have in Emacs packages, and the different ways they can
be configured, it would be a good first step.

Obvious one kind of electricity is when some keys (like ; } and such)
cause reindentation of the current line additionally to self-insert.

Other forms I would consider as potentially connected include:
- SPC in auto-fill-mode
- inserting () when you press just (
- do abbrev expansion when you hit SPC
- newline-and-indent as an electric form of newline
- insert `` or " or '' when you press " in LaTeX


        Stefan




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

* bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)
  2010-03-28 20:58   ` Daniel Colascione
  2010-03-28 22:37     ` Lennart Borgman
@ 2010-03-29  1:49     ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2010-03-29  1:49 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: Chong Yidong, 5586, Paul Pogonyshev

> 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






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

* bug#5586: is this bug still valid?
  2010-02-16 22:31 bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode) Paul Pogonyshev
  2010-03-26  5:03 ` Daniel Colascione
  2010-03-28 20:46 ` Chong Yidong
@ 2017-08-07  0:25 ` Tom Tromey
  2022-01-31 17:08   ` bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode) Lars Ingebrigtsen
  2 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2017-08-07  0:25 UTC (permalink / raw)
  To: 5586

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





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

* bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)
  2017-08-07  0:25 ` bug#5586: is this bug still valid? Tom Tromey
@ 2022-01-31 17:08   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-31 17:08 UTC (permalink / raw)
  To: Tom Tromey; +Cc: 5586

Tom Tromey <tom@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





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

end of thread, other threads:[~2022-01-31 17:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-16 22:31 bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode) Paul Pogonyshev
2010-03-26  5:03 ` Daniel Colascione
2010-03-28 20:46 ` Chong Yidong
2010-03-28 20:58   ` Daniel Colascione
2010-03-28 22:37     ` Lennart Borgman
2010-03-29  1:49     ` Stefan Monnier
2010-03-28 20:59   ` Daniel Colascione
2010-03-29  1:47   ` Electricity (was: bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode)) Stefan Monnier
2017-08-07  0:25 ` bug#5586: is this bug still valid? Tom Tromey
2022-01-31 17:08   ` bug#5586: 23.1.92.1; Electric indentation and hungry backspace deletion in JavaScript mode (js-mode) Lars Ingebrigtsen

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.