Emacs-Kotlin-Mode-Maintainers/kotlin-mode

fill-paragraph does not behave properly in comments

dchenbecker opened this issue · 0 comments

I noticed that if I manually wrap text in a comment, it does not handle the fact that it's in a comment. For example, with fill-column set to 10:

/**
 * This is a really long test with fill-column set to 10.
 */
class Foo : Bar() {
}

wraps to:

/** * This
is a
really
long test
with
fill-column
set to 10.
*/ class
Foo :
Bar() { }

But I would expect it to wrap to:

/**
 * This is 
 * a 
 * really
 * long
 * test
 * with 
 * fill-column
 * set to
 * 10.
 */
class Foo : Bar() {
}

That is, not wrap the code outside of the column, and to match the comment prefix asterisk. This is the behavior that java-mode exhibits. I've started looking at how java-mode handles this, but it's getting complicated quickly. I tried following what it's doing and set:

  (substitute-key-definition 'fill-paragraph 'c-fill-paragraph
			     kotlin-mode-map global-map)

But that doesn't work properly. I'm happy to help if someone can give me pointers on where to look.