zig-mode icon indicating copy to clipboard operation
zig-mode copied to clipboard

Incorrectly keeping prefix when using fill-region?

Open eatonphil opened this issue 2 years ago • 1 comments

Hey thanks for this! I start out with:

//Hey this is a really really really really really really really long line. 

And run fill-region on the line and get:

//Hey this is a really really really really really really really
long line.

The subsequent lines are incorrectly not commented.

Or another variation of it (before fill-region):

//Hey this is a really really really really really really really really really really
//long line.

And after fill-region:

//Hey this is a really really really really really really really
really really really //long line.

It doesn't preserve the comment markers in the right place.

Tangent

It would also be great if this was supported for multiline strings. Emacs does the wrong thing in zig-mode if I have:

\\Hey this is a really really really really really really really really really really
\\long line. 

And I call fill-region on that:

\\Hey this is a really really really really really really really
really really really \\long line. 

I'd hope that it preserves the string like I'd hope it preserves the comment.

Expected Behavior

In bash-mode if you do fill-region on a commented section, it fills the region keeping the comment prefix correctly.

(before fill-region)

#Hey this is a really really really really really really really really really really
#long line.

(after fill-region)

#Hey this is a really really really really really really really really
#really really long line.

eatonphil avatar Mar 08 '23 18:03 eatonphil

I wish zig-mode worked well out the box, but filladapt-mode seems to work for me.

https://www.emacswiki.org/emacs/FillAdapt

wmedrano avatar Aug 17 '24 03:08 wmedrano