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

Can't add trailing whitespace #127

Open Antisune opened 5 years ago

Antisune commented 5 years ago

The whitespace at the end of the current line is removed as I type it. ie. def sum(ints: List[Int]): Int = {

becomes

defsum(ints:List[Int]):Int={ Because every space character is deleted right after it is entered.

I already turned off electric-mode NOTE: this is only the case for my scala buffer, it is working as expected on my init.el

Malabarba commented 5 years ago

This is an unfortunate consequence of the fact that scala-mode removes whitespace at the end of the line when you try to indent. For instance, if you type def and then hit TAB, the space will be deleted and the cursor will move back a spot.

You can workaround this by doing this:

(add-to-list 'aggressive-indent-dont-indent-if 
             '(and (eq (char-before) ?\s) (looking-at-p "$")))

But I recommend reporting it as a bug on Scala-mode as well