aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes
diff options
context:
space:
mode:
authorRichard M. Stallman1993-08-02 05:55:56 +0000
committerRichard M. Stallman1993-08-02 05:55:56 +0000
commit47f3858d11f27453e6eeca07388a910c51df4dfd (patch)
tree8a9a09d60ad750fc87d9aa3a0bdf06c84d7a3b9a /lisp/textmodes
parent4524cb1c30ffb2402c782269e078fa571f65f341 (diff)
downloademacs-47f3858d11f27453e6eeca07388a910c51df4dfd.tar.gz
emacs-47f3858d11f27453e6eeca07388a910c51df4dfd.zip
(fill-region-as-paragraph): When we take one word
after the fill column, don't stop at period with just one space. When checking whether at beginning of line, if no fill prefix, ignore intervening whitespace.
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/fill.el33
1 files changed, 26 insertions, 7 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 57d7804657f..b5017b22a9d 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -165,12 +165,24 @@ From program, pass args FROM, TO and JUSTIFY-FLAG."
165 (eq (char-after (- (point) 2)) ?\.)) 165 (eq (char-after (- (point) 2)) ?\.))
166 (forward-char -2) 166 (forward-char -2)
167 (skip-chars-backward "^ \n" linebeg)) 167 (skip-chars-backward "^ \n" linebeg))
168 (if (if (zerop prefixcol) (bolp) (>= prefixcol (current-column))) 168 (if (if (zerop prefixcol)
169 (save-excursion
170 (skip-chars-backward " " linebeg)
171 (bolp))
172 (>= prefixcol (current-column)))
169 ;; Keep at least one word even if fill prefix exceeds margin. 173 ;; Keep at least one word even if fill prefix exceeds margin.
170 ;; This handles all but the first line of the paragraph. 174 ;; This handles all but the first line of the paragraph.
171 (progn 175 ;; Meanwhile, don't stop at a period followed by one space.
172 (skip-chars-forward " ") 176 (let ((first t))
173 (skip-chars-forward "^ \n")) 177 (move-to-column prefixcol)
178 (while (and (not (eobp))
179 (or first
180 (and (not (bobp))
181 (save-excursion (forward-char -1)
182 (looking-at "\\. ")))))
183 (skip-chars-forward " ")
184 (skip-chars-forward "^ \n")
185 (setq first nil)))
174 ;; Normally, move back over the single space between the words. 186 ;; Normally, move back over the single space between the words.
175 (forward-char -1)) 187 (forward-char -1))
176 (if (and fill-prefix (zerop prefixcol) 188 (if (and fill-prefix (zerop prefixcol)
@@ -179,9 +191,16 @@ From program, pass args FROM, TO and JUSTIFY-FLAG."
179 (substring fill-prefix 0 (- (point) (point-min))))) 191 (substring fill-prefix 0 (- (point) (point-min)))))
180 ;; Keep at least one word even if fill prefix exceeds margin. 192 ;; Keep at least one word even if fill prefix exceeds margin.
181 ;; This handles the first line of the paragraph. 193 ;; This handles the first line of the paragraph.
182 (progn 194 ;; Don't stop at a period followed by just one space.
183 (skip-chars-forward " ") 195 (let ((first t))
184 (skip-chars-forward "^ \n")))) 196 (while (and (not (eobp))
197 (or first
198 (and (not (bobp))
199 (save-excursion (forward-char -1)
200 (looking-at "\\. ")))))
201 (skip-chars-forward " ")
202 (skip-chars-forward "^ \n")
203 (setq first nil)))))
185 ;; Replace all whitespace here with one newline. 204 ;; Replace all whitespace here with one newline.
186 ;; Insert before deleting, so we don't forget which side of 205 ;; Insert before deleting, so we don't forget which side of
187 ;; the whitespace point or markers used to be on. 206 ;; the whitespace point or markers used to be on.