[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#6738: possible bug in fill-paragraph
From: |
Stephen Berman |
Subject: |
bug#6738: possible bug in fill-paragraph |
Date: |
Thu, 29 Jul 2010 23:04:22 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
On Tue, 27 Jul 2010 01:10:37 -0700 Eric De Mund <ead-gnu-emacs@ixian.com> wrote:
> 0. Invoke Emacs with "emacs -nw -q"
>
> 1. Start with this 3-line paragraph:
>
> A former executive testified that David H. Brooks misused company
> funds to buy a belt buckle encrusted with rubies, pornographic videos
> for his son and prostitutes for his workers.
>
> 2. Invoke << C-u 20 C-x f >> with cursor positioned on first word "A".
>
> 3. Invoke << M-1 M-q >>.
>
> 4. Observe paragraph reformatted to this, incorrectly:
>
> A former executive
> testified that David
> H. Brooks misused
> company funds to buy
> a belt buckle
> encrusted with
> rubies, pornographic
> videos for his son
> and prostitutes for
> his workers.
>
> i.e. with the 6th line ("encrusted with") taking up 21 columns
> rather than 20 columns.
It seems that the algorithm in justify-current-line doesn't work so well
for a two-word line: it correctly calculates the number of additional
space characters needed (ncols) but expects to fractionally distribute
them, as it does in the other lines, so it adds more space, in this case
wrongly. In such a situation, it suffices to just stick with ncols, as
in the following patch (but I haven't tested this in other cases, so
maybe it isn't the best fix).
Steve Berman
***/bzr/emacs/trunk/lisp/textmodes/fill.el 2010-05-29 13:10:05.000000000
+0200
---/bzr/emacs/quickfixes/lisp/textmodes/fill.el 2010-07-29 22:48:58.000000000
+0200
***************
*** 1296,1302 ****
(while (> count 0)
(skip-chars-forward " ")
(insert-and-inherit
! (make-string (/ curr-fracspace nspaces) ?\s))
(search-forward " " nil t)
(setq count (1- count)
curr-fracspace
--- 1296,1303 ----
(while (> count 0)
(skip-chars-forward " ")
(insert-and-inherit
! (make-string
! (min ncols (/ curr-fracspace nspaces)) ?\s))
(search-forward " " nil t)
(setq count (1- count)
curr-fracspace