From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Samuel Freilich Newsgroups: gmane.emacs.bugs 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 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a11441e5ed9763e05180a2604 X-Trace: ger.gmane.org 1433807506 28378 80.91.229.3 (8 Jun 2015 23:51:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 8 Jun 2015 23:51:46 +0000 (UTC) To: 20774@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 09 01:51:33 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z26pI-0006LF-8z for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Jun 2015 01:51:32 +0200 Original-Received: from localhost ([::1]:60612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z26pH-0000DB-Ci for geb-bug-gnu-emacs@m.gmane.org; Mon, 08 Jun 2015 19:51:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z26pD-0000D6-Qa for bug-gnu-emacs@gnu.org; Mon, 08 Jun 2015 19:51:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z26k0-00024X-2a for bug-gnu-emacs@gnu.org; Mon, 08 Jun 2015 19:46:28 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35556) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z26jz-00024B-UM for bug-gnu-emacs@gnu.org; Mon, 08 Jun 2015 19:46:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Z26jz-0000BR-Eu for bug-gnu-emacs@gnu.org; Mon, 08 Jun 2015 19:46:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Samuel Freilich Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Jun 2015 23:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 20774 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1433807108631 (code B ref -1); Mon, 08 Jun 2015 23:46:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Jun 2015 23:45:08 +0000 Original-Received: from localhost ([127.0.0.1]:45531 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z26j2-00009y-K9 for submit@debbugs.gnu.org; Mon, 08 Jun 2015 19:45:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45799) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z26di-0008TN-VW for submit@debbugs.gnu.org; Mon, 08 Jun 2015 19:39:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z26dc-0006bH-FJ for submit@debbugs.gnu.org; Mon, 08 Jun 2015 19:39:29 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:49110) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z26dc-0006bD-Ba for submit@debbugs.gnu.org; Mon, 08 Jun 2015 19:39:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z26da-0005JA-Nn for bug-gnu-emacs@gnu.org; Mon, 08 Jun 2015 19:39:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z26dZ-0006al-7W for bug-gnu-emacs@gnu.org; Mon, 08 Jun 2015 19:39:26 -0400 Original-Received: from mail-qk0-x236.google.com ([2607:f8b0:400d:c09::236]:34273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z26dZ-0006a7-1v for bug-gnu-emacs@gnu.org; Mon, 08 Jun 2015 19:39:25 -0400 Original-Received: by qkoo18 with SMTP id o18so1223062qko.1 for ; Mon, 08 Jun 2015 16:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=y07DCusFza6ao5dxtjMdzbYwelzNDKt7H2GoH29LSgo=; b=nHgiLPysDQf3p1MIlwAgQvJ6YYfCTtOfWkCn3S3qOxNJ9huABQsr7pQIUhgMd6gCAu /NQak1a0JT0vC/EeHSQ/rOOiAjGbjbm3vwG9KCE9prXKZAW8+i4hT462/3mQcWZbcG+b 2FOkoCKgXKlpnefyGm1AdLpA8bvYS+A+Ir9/WZwrhytZfZEbRIHMthXieb+RVFqsQXQ8 hR03tQgaWt8FwFYvv5dVGiTyCULADxa0a+CvSXOZyxRJzJK+JEseJIVIGVWmEL8QulK+ DKIa0cb8QjKYJp03zZkDGCHXOEcd1f6fgZTx5PsMWDf7+5Xfu8K7+ldGVvl2vQdAhBfj WBBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-type; bh=y07DCusFza6ao5dxtjMdzbYwelzNDKt7H2GoH29LSgo=; b=jHopfhgaMMt51kxbTW0c/vSIpCjX8F5Eh76MuRDwcu+QDvnmvDPC3Yighkhdtse8Zf PngEPq9/XOME9ZlfTmn9AxQD3eHvoDLMG0anUNnP/7s849k+CTaFB/hWJYI+AmGTiyxC ZwvR94zjrhfB59ua0co48qFBtcTAaIcSPAgSIAMNCXPTegvQYU7y/f0vG17nBMHPnjH5 GgJc/0jFXtClTu35WgmdvbDpS6mYBikVmulQDRpRuyqVHXr/7Ha0Paz3nVISZXr30EO5 5fHueOgxl1eheEe7x7uFleR1e6aWVWkUTmvBfqhFE/BLTFHBF1OTaoyu3qR1MEH7afZD B0jQ== X-Gm-Message-State: ALoCoQllu/jyDsTCpLs3Lw9mXmmxcm9iLWYKQhTz9Y9iryktIH0VD4M+uywDu8LHTbXvID8fr/fU X-Received: by 10.55.24.149 with SMTP id 21mr36972057qky.97.1433806764059; Mon, 08 Jun 2015 16:39:24 -0700 (PDT) Original-Received: by 10.140.87.119 with HTTP; Mon, 8 Jun 2015 16:39:03 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Mailman-Approved-At: Mon, 08 Jun 2015 19:45:01 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:103761 Archived-At: --001a11441e5ed9763e05180a2604 Content-Type: multipart/alternative; boundary=001a11441e5ed9763905180a2602 --001a11441e5ed9763905180a2602 Content-Type: text/plain; charset=UTF-8 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 --001a11441e5ed9763905180a2602 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
The function do-auto-fill doesn't consider that in ada= ptive-fill-mode, the first line's prefix might not match the fill-prefi= x for subsequent lines.

For example, markdown-mode confi= gures adaptive-fill-mode so that when filling list item paragraphs, there&#= 39;s a hanging indent:

* =C2=A0 List item...
=
=C2=A0 =C2=A0 next line...

Currently, there&#= 39;s a bug where auto-fill-mode will break lines at the start of a list ite= m, even though the resulting line is just as long, e.g.:


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 le= ngth of that line, it becomes:

* =C2=A0=C2=A0
=C2=A0 =C2=A0[link](http://a-really-long-url.ex= ample.com/...)

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

The a= ttached patch fixes this by ensuring that a line will be broken by auto-fil= l 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 whe= n finding a point to break (that is, the line should not be broken in the m= iddle of the prefix), even if the first-line prefix differs from the fill-p= refix for subsequent lines.


Deta= iled Reproduction Steps:


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

Type the following into t= he buffer and hit RET:
* Item

Actual res= ult:
*
=C2=A0 Item
=C2=A0 [cursor]
=
Expected result:
* Item
=C2=A0 [cursor]<= /div>

Peace,
-Sam
--001a11441e5ed9763905180a2602-- --001a11441e5ed9763e05180a2604 Content-Type: text/x-patch; charset=US-ASCII; name="emacs-auto-fill-different-first-line.patch" Content-Disposition: attachment; filename="emacs-auto-fill-different-first-line.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_iaojaqfr0 KioqIHNpbXBsZS5lbC5vbGQJMjAxNS0wNi0wOCAxOToxOToyMC40ODQzOTczODcgLTA0MDAKLS0t IHNpbXBsZS5lbC5uZXcJMjAxNS0wNi0wOCAxOToxODo1OC4zNDAzMDUzMDEgLTA0MDAKKioqKioq KioqKioqKioqCioqKiA2NTU5LDY1NzUgKioqKgogIAkgICAgICAgKHNldHEgZmlsbC1wcmVmaXgg cHJlZml4KSkpKQogIAogICAgICAgICh3aGlsZSAoYW5kIChub3QgZ2l2ZS11cCkgKD4gKGN1cnJl bnQtY29sdW1uKSBmYykpCiEgCTs7IERldGVybWluZSB3aGVyZSB0byBzcGxpdCB0aGUgbGluZS4K ISAJKGxldCogKGFmdGVyLXByZWZpeAogIAkgICAgICAgKGZpbGwtcG9pbnQKICAJCShzYXZlLWV4 Y3Vyc2lvbgogIAkJICAoYmVnaW5uaW5nLW9mLWxpbmUpCiEgCQkgIChzZXRxIGFmdGVyLXByZWZp eCAocG9pbnQpKQohIAkJICAoYW5kIGZpbGwtcHJlZml4CiEgCQkgICAgICAgKGxvb2tpbmctYXQg KHJlZ2V4cC1xdW90ZSBmaWxsLXByZWZpeCkpCiEgCQkgICAgICAgKHNldHEgYWZ0ZXItcHJlZml4 IChtYXRjaC1lbmQgMCkpKQogIAkJICAobW92ZS10by1jb2x1bW4gKDErIGZjKSkKISAJCSAgKGZp bGwtbW92ZS10by1icmVhay1wb2ludCBhZnRlci1wcmV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