bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20774: auto-fill doesn't work properly when first-line prefix differ


From: Samuel Freilich
Subject: bug#20774: auto-fill doesn't work properly when first-line prefix differs in adaptive-fill-mode
Date: Mon, 8 Jun 2015 19:39:03 -0400

The function do-auto-fill doesn't consider that in adaptive-fill-mode, the first line's prefix might not match the fill-prefix for subsequent lines.

For example, markdown-mode configures adaptive-fill-mode so that when filling list item paragraphs, there's a hanging indent:

*   List item...
    next line...

Currently, there's a bug where auto-fill-mode will break lines at the start of a list item, even though the resulting line is just as long, e.g.:

*   [link](http://a-really-long-url.example.com/...)

When you hit enter at the end of the line in markdown-mode with autofill on and the fill-column set to less than the length of that line, it becomes:

*   
   [link](http://a-really-long-url.example.com/...)

That's incorrect behavior because the prefix added after breaking the line is just as long as the line up to the point before the break.

The attached patch fixes this by ensuring that a line will be broken by auto-fill only if the position is further along in the line than the length of the fill prefix. It also ensures that the first-line fill prefix is skipped when finding a point to break (that is, the line should not be broken in the middle of the prefix), even if the first-line prefix differs from the fill-prefix for subsequent lines.


Detailed Reproduction Steps:

Get markdown-mode from:
http://jblevins.org/projects/markdown-mode/markdown-mode.el

$ emacs -Q -l markdown-mode.el
M-x markdown-mode RET
M-x auto-fill-mode RET
M-x set-fill-column RET 5 RET

Type the following into the buffer and hit RET:
* Item

Actual result:
*
  Item
  [cursor]

Expected result:
* Item
  [cursor]

Peace,
-Sam

Attachment: emacs-auto-fill-different-first-line.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]