Subject: Re: bug#13949: 24.4.1; `fill-paragraph' should not always put the buffer as modified

From: Jaakov <[email-masked]>
Date: Tue, 22 Mar 2016 18:52:14 +0100

Another implementation to fill paragraph in text mode could have as well 
scanned through the text linewise as suggested by Stefan Monnier.

I would implement just line splitting along the following idea for 
text-mode (not in LISP - please excuse me):

FOR EACH line l in the current paragraph
   REMARK space = whitespace or TAB
   c := rightmost column of l with space or -1 if none found
   IF c >= fill-column => 0 THEN
     REPEAT
       c' := c
       c := rightmost column of l|_{[0,c'[} with space
            or -1 if none found
     UNTIL c < fill-column
     IF c<0 THEN
       split line l at column c'
     ELSE
       split line l at column c
     ENDIF
     modifies := true
   END IF
END FOR

Of course, fill-paragraph needs to be much more than line splitting, so 
don't take my terrible piece of code too seriously, i.e., for anything 
except the initial idea.