🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98711

suggested fix for fill-paragraph problem

#98711
From: Scott D Kalter
Date: Thu, 14 Mar 1991 15:06
74 lines
3237 bytes
In article:

	From: ps106363@LEHTORI.TUT.FI (Pasi Sainio)
	Newsgroups: gnu.emacs.bug
	Subject: Bug in (fill-paragraph)
	Date: 8 Mar 91 11:41:03 GMT
	Distribution: gnu
	Organization: GNUs Not Usenet

Pasi describes an annoying bug introduced into fill-paragraph some
time after 18.54.  I found a small fix for 18.57.  However, I don't
have copies of old emacs versions and simply reverting to the last
working version may be better.

The problem only seems to occur when doing justification.  The culprit
is justify-current-line().  Here is the relevent context diff:

*** /reb/src/base/emacs/lisp/fill.el	Wed Jan  9 13:58:18 1991
--- /tmp/fill.el	Thu Mar 14 09:48:51 1991
***************
*** 138,147 ****
    (interactive)
    (save-excursion
     (save-restriction
!     (let (ncols beg)
        (beginning-of-line)
        (forward-char (length fill-prefix))
        (skip-chars-forward " \t")
        (setq beg (point))
        (end-of-line)
        (narrow-to-region beg (point))
--- 138,148 ----
    (interactive)
    (save-excursion
     (save-restriction
!     (let (ncols beg indent)
        (beginning-of-line)
        (forward-char (length fill-prefix))
        (skip-chars-forward " \t")
+       (setq indent (- (current-column) (length fill-prefix)))
        (setq beg (point))
        (end-of-line)
        (narrow-to-region beg (point))
***************
*** 159,165 ****
  	(forward-char -1)
  	(insert ? ))
        (goto-char (point-max))
!       (setq ncols (- fill-column (current-column)))
        (if (search-backward " " nil t)
  	  (while (> ncols 0)
  	    (let ((nmove (+ 3 (% (random) 3))))
--- 160,166 ----
  	(forward-char -1)
  	(insert ? ))
        (goto-char (point-max))
!       (setq ncols (- fill-column (current-column) indent))
        (if (search-backward " " nil t)
  	  (while (> ncols 0)
  	    (let ((nmove (+ 3 (% (random) 3))))

My goal was to change as little as possible.  Clearly more a few more
changes could make for some better code (calculate the length of
fill-prefix only once, etc.).

The problem is that we skip the fill-prefix and then any additional
leading white space.  However, we only record having skipped the
fill-prefix.  When the number of spaces to insert into the line
(ncols) is calculated we get a value that was too large and therefore
the line is filled past the fill column.  I simply added a variable
(indent) to record how much additional white space was skipped and
used this in the calculation of ncols.

-sdk
Technical Details
Message-ID: <SDK.91Mar14100618@shadow.twinsun.com>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!decwrl!sdd.hp.com!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,6a8d47c7bee4792e,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-03-14 07:06:18 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!decwrl!sdd.hp.com!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage
From: twinsun!shadow!sdk@UUNET.UU.NET (Scott D Kalter)
Newsgroups: gnu.emacs.bug
Subject: suggested fix for fill-paragraph problem
Message-ID: <SDK.91Mar14100618@shadow.twinsun.com>
Date: 14 Mar 91 15:06:18 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: Twin Sun, Inc.
Lines: 74
Approved: bug-gnu-emacs@prep.ai.mit.edu