GNU bug report logs - #6738
possible bug in fill-paragraph

Previous Next

Package: emacs;

Reported by: Eric De Mund <ead-gnu-emacs <at> ixian.com>

Date: Tue, 27 Jul 2010 14:44:01 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6738 in the body.
You can then email your comments to 6738 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6738; Package emacs. (Tue, 27 Jul 2010 14:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eric De Mund <ead-gnu-emacs <at> ixian.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 27 Jul 2010 14:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eric De Mund <ead-gnu-emacs <at> ixian.com>
To: bug-gnu-emacs <at> gnu.org
Subject: possible bug in fill-paragraph
Date: Tue, 27 Jul 2010 01:10:37 -0700
Hello,

Here's a possible bug in fill-paragraph. In my twenty years of using
Emacs (and fill-paragraph), I've never come across something like this.

In addition to observing this bug with:
    In GNU Emacs 22.2.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
    of 2008-11-09 on raven, modified by Debian
running under:
    Debian 5.0.5 Lenny
, I've reproduced it with:
    GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600) of 2010-05-08 on G41R2F1
running under:
    Windows XP Professional
    Build 2600.xpsp_sp3_gdr.100216-1514 (Service Pack 3)    

Here are the gory details:

--------CUT HERE----BEGIN SECTION 1 OF 2--------

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.

--------CUT HERE----BEGIN SECTION 2 OF 2--------

In GNU Emacs 22.2.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2008-11-09 on raven, modified by Debian
configured using `configure '--build=i486-linux-gnu'
'--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib'
'--libexecdir=/usr/lib' '--localstatedir=/var/lib'
'--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs22:\
/etc/emacs:/usr/local/share/emacs/22.2/site-lisp:\
/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.2/site-lisp:\
/usr/share/emacs/site-lisp:/usr/share/emacs/22.2/leim'
'--with-x=yes' '--with-x-toolkit=athena' '--with-toolkit-scroll-bars'
'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu'
'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Fundamental

Minor modes in effect:
  encoded-kbd-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
ESC x r e p o r t - e m a c s - b u g RET

Recent messages:
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading emacsbug...
/usr/bin/mail is not an executable.  Setting mail-interactive to t.
Loading regexp-opt...done
Loading emacsbug...done

--------CUT HERE----END SECTION 2 OF 2--------

If you need more information, please don't hesitate to ask.

Regards,
Eric
--
Eric De Mund
ead-gnu-emacs <at> ixian.com




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6738; Package emacs. (Thu, 29 Jul 2010 21:05:02 GMT) Full text and rfc822 format available.

Message #8 received at 6738 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Eric De Mund <ead-gnu-emacs <at> ixian.com>
Cc: 6738 <at> debbugs.gnu.org
Subject: Re: bug#6738: possible bug in fill-paragraph
Date: Thu, 29 Jul 2010 23:04:22 +0200
On Tue, 27 Jul 2010 01:10:37 -0700 Eric De Mund <ead-gnu-emacs <at> 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 sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 02 Aug 2010 15:56:02 GMT) Full text and rfc822 format available.

Notification sent to Eric De Mund <ead-gnu-emacs <at> ixian.com>:
bug acknowledged by developer. (Mon, 02 Aug 2010 15:56:02 GMT) Full text and rfc822 format available.

Message #13 received at 6738-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: Eric De Mund <ead-gnu-emacs <at> ixian.com>
Subject: Re: bug#6738: possible bug in fill-paragraph
Date: Mon, 02 Aug 2010 12:27:31 +0200
> 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).

I've changed the curr-fracspace calculation instead.  Not sure why it
was doing a +1 on nspaces, and removing it fixes this problem (I'm not
sure it doesn't introduce another one, but at least my tests lead me to
think that's not the case).


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 31 Aug 2010 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 290 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.