pombreda / js2-mode

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

indent-for-tab-command broken #83

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Move the point to the whitespace at the beginning of a line
2. Press TAB

What is the expected output? What do you see instead?
Point should move to first non-whitespace character. Instead it doesn't move.
The documentation for indent-for-tab-command says:
If initial point was within line's indentation, position after
the indentation.  Else stay at same point in text.

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

Please provide any additional information below.

Original issue reported on code.google.com by rib...@gmail.com on 20 Jun 2008 at 4:11

GoogleCodeExporter commented 9 years ago
In other words, if we're in the indentation, and we press TAB, we should jump 
to the
end of the indentation before we begin bounce-indenting to agree with
indent-for-tab-command's docstring. Here's a patch to do that.

Original comment by dmho...@gmail.com on 18 Jul 2008 at 9:29

Attachments:

GoogleCodeExporter commented 9 years ago
Incidentally, modes derived from cc-mode also behave in this way. E.g. (! 
represents
point):

M-x c-mode

int foo();
!    bar();
}

TAB

int foo();
  !bar();
}

However, TAB runs c-indent-command, rather than indent-for-tab-command, so 
they're
not violating any documentation.

Original comment by dmho...@gmail.com on 25 Jul 2008 at 9:37

GoogleCodeExporter commented 9 years ago
Also worth noting: haskell-mode, which also does bounce-indenting (and has TAB 
bound
to indent-for-tab-command), behaves as follows: 

1. If the current line is indented to one of the valid indent stops for this 
line,
and the point is in the indentation, call (back-to-indentation).

2. If the current line is indented to one of the valid indent stops for this 
line,
but the point isn't in the indentation, bounce indent.

3. If the current line is not indented to one of the valid indent stops for this
line, (back-to-indentation) and bounce indent.

So this policy is another option.

Original comment by dmho...@gmail.com on 31 Jul 2008 at 1:22

Attachments:

GoogleCodeExporter commented 9 years ago
Oh, typo in my comment #2: I of course meant: 

int foo() {
!    bar();
}

TAB

int foo() {
  !bar();
}

(I have c-basic-offset set to 2, by the way.)

Original comment by dmho...@gmail.com on 31 Jul 2008 at 1:23

GoogleCodeExporter commented 9 years ago
Thanks for your patch, dmhouse. It doesn't work quite as I expect, though, 
because I'm used to TAB still indenting the current line, even if it does 
(back-to-indentation). Here's the fix I'm using:

http://github.com/ramen/emacs-starter-kit/commit/bbaceecf35404dc1022809571a609f6
8b2b33c69

Regards,
Dave

Original comment by dave.ben...@gmail.com on 28 Sep 2010 at 10:53