Malabarba / aggressive-indent-mode

Emacs minor mode that keeps your code always indented. More reliable than electric-indent-mode.
850 stars 36 forks source link

reindent when unfinished line is killed in c-mode #70

Closed Dickby closed 8 years ago

Dickby commented 8 years ago

Hi, I truly love this package! But there is one case in c-mode that could be improved in my opinion: If I open a new line inside an existing function and start to type, the next lines are indented one more step as long as I don't type the finishing semicolon. Thats fine! But if I deside to kill that line again before typing the semicolon (with C-a C-k C-k) the following lines aren't jumping back again. This is the only case I know where I need to indent manually. Thanks

Malabarba commented 8 years ago

Hm. That definitely sounds like a bug. Could you provide an example snippet where that happens?

Dickby commented 8 years ago

Start emacs with -q, open a new file in c-mode, enable only aggressive-indent-mode. type the following c code:

#include <stdio.h>
int main()
{
printf("hello, world!\n");
|
return 0;
}

'|' is where the cursor should be. Now type printf where the cursor is and the return 0; will be indented one step deeper. If you now delete the line with "C-a C-k C-k" the return 0; line stays where it is and doesn't jump back.

ynnebhc commented 8 years ago

Hello,

I run into the same issue in cc-mode as Dickby described above in rev 1.5 with the latest Emacs 24 release.

Another observation after this issue is that c-c c-q on the messed-up code seems not working any more. I have to re-load the file in order to make it work.

Thanks a lot.

Malabarba commented 8 years ago

Done, let me know if it works. :+1:

Dickby commented 8 years ago

It works only sometimes. Even on the same line the bahavior differs.

I don't know if this helps, but I solved it for me by disabling line 320 in aggressive-indent-indent-region-and-on in aggressive-indent.el:

(forward-line 1)

Malabarba commented 8 years ago

It works only sometimes. Even on the same line the bahavior differs.

You'll have to be a little more specific. ☺ Is there anything you do that triggers it now?