unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Eric De Mund <ead-gnu-emacs@ixian.com>
Cc: 6738@debbugs.gnu.org
Subject: bug#6738: possible bug in fill-paragraph
Date: Thu, 29 Jul 2010 23:04:22 +0200	[thread overview]
Message-ID: <871vamgfu1.fsf@escher.home> (raw)
In-Reply-To: <19534.38013.458365.325249@ixian.com> (Eric De Mund's message of "Tue, 27 Jul 2010 01:10:37 -0700")

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





  reply	other threads:[~2010-07-29 21:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-27  8:10 bug#6738: possible bug in fill-paragraph Eric De Mund
2010-07-29 21:04 ` Stephen Berman [this message]
2010-08-02 10:27   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871vamgfu1.fsf@escher.home \
    --to=stephen.berman@gmx.net \
    --cc=6738@debbugs.gnu.org \
    --cc=ead-gnu-emacs@ixian.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).