🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98919

Problems with fill-individual-paragraphs in fill.el

#98919
From: hilfingr
Date: Mon, 11 Feb 1991 18:33
96 lines
5152 bytes
I have found two problems with the fill-individual-paragraphs function
in my version of fill.el.  You will see both of them if you load the
first bunch of text below into a buffer by itself and evaluate
	(fill-individual-paragraphs (point-min) (point-max) t t)
in that buffer.  You will note imperfect justification in paragraphs
containing colons and at the ends of some paragraphs.

We are running GNU Emacs version 18.55.12; the latest entry in the
ChangeLog entry in the .../lisp directory is dated 15 Aug 1989 at
21:41:10.

Below the example, I have also included the fix that I am using at the
moment and an explanatory ChangeLog-like entry for it, should you find
it useful.

------------------------------ cut here ------------------------------
x xxxxxxxxx xx xxxxxx xxx xxxx xxx xxxxxxxxx xxxx xxxx xx xxxxxxx xxx
xxxxxxxxxx.  x xxxx, xxxxxxx, xxxx xxxx xxxxxxxxxx xxxxxxxxxxx xxxxx
xxxx xx xxxxx xx xxxxxxx xxxxx.

xxxxxx xxxxx'x xxxxxxxxxxxx xx xxx xxxxxxxx xxxxxxxxx xx xxxxxx
xxxxxxxxx xx xxx xxxxxxx xxx, xxxxxx'x xxxxxxxx xxxxxxxxxxxxxxx.
xxxxxx xxx xxxx xxxx xxxx xxxxxxxxx xxxxxxx xxxx xxx xxxxxxxxx xx
xxxxxx xxxxxxxxx xx xxxxxx xxxxxxxx xx xxx 83.  xxxx xxxxxx'x
xxxxxxxxxxx xx xxxx xxx xxxxx xxx xxxxxx xx xxxxxxxxxx, x xxxxxxx xxx
xxxxxxxxxxxxxx xxxx xxxxx xxxxxxx xxx xxxxxx xx xxxxxx xxxxxxxxx xxxx
xxxxxxxxxxxxxxx xxxxxx xxxx xxxx xxx xxxx.  xxx xx xxxxxxx, xxxxxxxxx,
xxxxxxx, xxx xxxxxxxx xxxxxxx, xxx xx xxxxxxxxxx xxx xxxxxxx xx xxxxxx
xxxxxx xx xxxxxxx xxx, xxxxx xxxxx xxxx xx xxxx xxx xxx 9x, xxxx
xxxxxxxx xxxxxxxxx.  x xxxx xxxx xx xx xx xxxx xxxxxxx xxxxxxxx xx
xx-xx08.


xxxxx xxx xxx 83 xxxxxx xxxxxxxxx

xxxxx, xxxx xxxxxxxxxxxxx.  x xxxxx xxx xxxxxxxxx (xxxxxxxx xxxxxx
xxxxxxxx) xxxxxxxxxxx xxxxx xx xxx xxxxxxx: xxxx xxxx xxxxxxxxx x
xxxxxxxx xx xxxxxx, xxx xxx xxxxxx xxxxxxx xxxxx xx x xxxxx xxxxxxxxx
xx xxxxxxxxxxxx xx xxxxx xxxxxx, xxxx xxxxxxx xxxxxx, xxxxxxxxxxxxx
xxxxxx, xxxxxxxxxx ("xxxx xx xxx xx xxxx xxxxx").  xxxxxxxxxx, xxxx
xxxxxxxxx xxxxxxxxx xx xx xxxxx.  xxxxxxxxxxxxxxx xxxxxx xxxx xxx
xxxxxxxxx xx x xxxxxxxxxx xxx xxxxxx xxxx xxxxx xx xxxxxxxx xxxxx xxx
xxx xxxxxxx xx x xxxxxx xxxxx xx xxx xxxxxxxxxxxx.  x xxxx xx x
xxxxxxxx xxxxxxxx xx xxxx xxxxxxxx xx "xxxx xxxxxx"---x xxxxxxxx
xxxxxxx xxx xxxxxxxx xxx xxx xx xxxxxxxxxxx xxxxxxxx.  xxxxxxxx, x
xxxxx xx x xxxxxxxx xxxxxxxx xx xxxx xxxxxxxx xx "xxxxx xxxxxx".  xxx
xxxxxxxx xxxxxxxx, xxx xxxxx xxxxxxxxx xxxx x xxxx xxx xxxxxxxx xxx
xxx "xxxxxxxxx" xxxxxxxxx xxxxxxxxx xx xxx xxxxxxxxx xxxxxx (xxxxxxx
xxxxxxxxx xx xxxxxxx xxxxxx xxxxxxxx xxxxx xxx xxx xxxxxx).  x xxx xxx
xxxxxx "xxxxxxxxx" xxxx xx xxxxx xxx xxx-xxxxxxxxxxxxx xxxxx xx xxx
xxxxxx.
------------------------------ cut here ------------------------------

Possible replacement for fill-individual-paragraphs:

------------------------------ cut here ------------------------------

(defun fill-individual-paragraphs (min max &optional justifyp mailp)
  "Fill each paragraph in region according to its individual fill prefix.
Calling from a program, pass range to fill as first two arguments.
Optional third and fourth arguments JUSTIFY-FLAG and MAIL-FLAG:
JUSTIFY-FLAG to justify paragraphs (prefix arg),
MAIL-FLAG for a mail message, i. e. don't fill header lines."
  (interactive "r\nP")
  (let (fill-prefix)
    (save-restriction
      (save-excursion
	(narrow-to-region min max)
	(goto-char (point-min))
	(if mailp 
	    (while (re-search-forward "\\`[^ \t\n]*:" (point-max) t)
	      (forward-line 1)
	      (narrow-to-region (point) (point-max))))
	(while (progn
		 (skip-chars-forward " \t\n")
		 (not (eobp)))
	  (setq fill-prefix 
		(buffer-substring (point) (progn (beginning-of-line) (point))))
	  (let ((fin (save-excursion (forward-paragraph) (point)))
		(start (point)))
	    (fill-region-as-paragraph start fin justifyp)
	    (goto-char start)
	    (forward-paragraph)))))))

------------------------------ cut here ------------------------------

Explanatory ChangeLog-like entry:

Mon Feb 11 13:07:37 1991  Paul Hilfinger  (hilfingr at hilfinger.cs.nyu.edu)

	* fill.el (fill-individual-paragraphs): Changed response to mailp
	to effect only leading lines in a region (was getting confused
	about colons embedded in ordinary text).  Changed method of
	moving to next paragraph in the main loop to use forward-paragraph
	rather than goto-char, since the final character position is
	rendered obsolete by the intervening fill-region-as-paragraph.
Technical Details
Message-ID: <9102111833.AA02482@HILFINGER.CS.NYU.EDU>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!HILFINGER.CS.NYU.EDU!hilfingr

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,11d63dd625088b64,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-02-11 10:33:29 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!HILFINGER.CS.NYU.EDU!hilfingr
From: hilfingr@HILFINGER.CS.NYU.EDU
Newsgroups: gnu.emacs.bug
Subject: Problems with fill-individual-paragraphs in fill.el
Message-ID: <9102111833.AA02482@HILFINGER.CS.NYU.EDU>
Date: 11 Feb 91 18:33:29 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 96
Approved: bug-gnu-emacs@prep.ai.mit.edu