Juan571 / js2-mode

Automatically exported from code.google.com/p/js2-mode
0 stars 0 forks source link

Surprising backward-sexp behavior #46

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. In js2-mode buffer, insert the following sans point marker:

if (true)<POINT> {
}

2. With cursor at <POINT>, invoke backward-sexp (typically C-M-b).

What is the expected output? What do you see instead?

I use this function frequently in other modes, so I have a hardwired
expectation that it will move to the matching start paren, as it does
normally (and by normal in this case, I mean lisp-mode, which is rather
abnormal in a way). In this case, though, it jumps before the if ...

<ACTUAL>if <EXPECTED>(true) {
}

I'm really not sure if this is a bug or if this was intended ... I run into
it quite frequently though. If it's just me, I can pretty easily work
around it in my mode hook, so no big deal.

What version of the product are you using? On what operating system?

js2-mode-version is a variable defined in `js2-mode.el'.
Its value is 20080413
GNU Emacs 22.2.50.1 (i386-mingw-nt6.0.6001)
 of 2008-04-07 on SLAG

Original issue reported on code.google.com by dereksla...@gmail.com on 18 Apr 2008 at 7:09

GoogleCodeExporter commented 8 years ago
It's intentional, although I'm not 100% sure if it's going to survive 
long-term. 
Depends on how other people feel about it.

The rationale is that a "sexp" in JavaScript is a statement or expression, 
which can
include cruft outside the braces.  It seems more likely that people will want to
mark/narrow-to/navigate entire statements.

I might split out the functionality somehow to offer both - e.g. with prefix 
arg, it
defaults to the lisp version, or something.  We'll see.

Original comment by steve.ye...@gmail.com on 19 Apr 2008 at 9:08