[gnu.emacs] Filling of paragraphs in GNU emacs.

hjanssen@cbnewse.ATT.COM (hank janssen) (11/22/89)

Does anybody out there knows or has a lisp library function call  
somewhere  that will automaticly  (or via a keystroke) perfectly
fill a paragraph i am editing. It seems that fill-paragraph does
not  do what i  want it  to do. If you  wonder what i mean  with 
filling a paragraph than just look at this piece of text. 

Thanx
					Hank Janssen.
				
-----------------------------------------------+----------------------
It's better to burn out than to fade away......| uucp:
			Movie The HighLander.  | ...att!ihlpb!hjanssen
-----------------------------------------------+----------------------

mende@athos.rutgers.edu (Bob Mende Pie) (11/24/89)

  The fill-paragraph function will justify if you give it a argument.  This
is an example of doing a  fill paragraph with  an argument... I  hope it is
want you want.

					/Bob...
-- 
{...}!rutgers!mende         mende@cs.rutgers.edu          mende@zodiac.bitnet

ashwin@gatech.edu (Ashwin Ram) (12/05/89)

In article <49028@bbn.COM> John Robinson writes:
>   Ashwin Ram has a much improved version of justify-current-line, which
>   is due to get into the distribution some day.  He sent it to me but I
>   didn't keep a copy.  Perhaps he will post it here.

I've gotten a couple of requests for this, so here goes:
------------------------------------------------------------------------------
; Rewrote to spread blanks evenly across inter-word spaces in line.  Randomly
; decide whether to put extra spaces from the right or the left, to avoid
; "rivers" as far as possible.  Don't modify original interword spaces.
; Ashwin Ram, 11/16/87.
(defun justify-current-line ()
   "Add spaces to line point is in, so it ends at fill-column."
   (interactive)
   (save-excursion
      (save-restriction
         (beginning-of-line)
         (skip-chars-forward " \t")
         (let ((begin (point)))
            (end-of-line)
            (narrow-to-region begin (point))
            (let ((blanks (- fill-column (current-column))))
               (if (<= blanks 0)
                   nil
                   (goto-char begin)
                   (let ((holes 0))
                      (while (re-search-forward "[ \t][^ \t]" nil t)
                         (setq holes (+ holes 1)))
                      (let ((each (/ blanks holes))
                            (extra (% blanks holes))
                            (dir (> (random) 0))
                            (count 1))
                         (end-of-line)
                         (while (<= count holes)
                            (re-search-backward "[ \t][^ \t]")
                            (let ((n 1))
                               (while (<= n each)
                                  (insert ? )
                                  (setq n (+ n 1))))
                            (if dir
                                (if (<= count extra) (insert ? ))
                                (if (>= count (- holes (- extra 1))) (insert ? )))
                            (setq count (+ count 1)))))))))))
------------------------------------------------------------------------------

-- Ashwin (ashwin@gatech.edu)
--
Ashwin Ram
Georgia Institute of Technology, Atlanta, Georgia 30332-0280
UUCP:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!ar17
Internet: ashwin@gatech.edu, ashwin@pravda.gatech.edu, ar17@prism.gatech.edu