aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-03-09 06:37:20 +0000
committerRichard M. Stallman1998-03-09 06:37:20 +0000
commita0d8840a5a9348196336e45419bb4c4ebfd4b905 (patch)
tree85b53810b9699f3fc75d84816eaa95e6d36facba
parentdbe524b6329f13700951c1f1617ff06ef7692a20 (diff)
downloademacs-a0d8840a5a9348196336e45419bb4c4ebfd4b905.tar.gz
emacs-a0d8840a5a9348196336e45419bb4c4ebfd4b905.zip
(fill-nobreak-predicate): New variable.
(fill-region-as-paragraph): Obey fill-nobreak-predicate.
-rw-r--r--lisp/textmodes/fill.el28
1 files changed, 20 insertions, 8 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 08a285b2aaa..eb1d2a9ef42 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -247,6 +247,11 @@ act as a paragraph-separator."
247 (concat result "a")))) 247 (concat result "a"))))
248 result))))))) 248 result)))))))
249 249
250(defvar fill-nobreak-predicate nil
251 "If non-nil, a predicate for recognizing places not to break a line.
252The predicate is called with no arguments, with point at the place
253to be tested. If it returns t, fill commands do not break the line there.")
254
250(defun fill-region-as-paragraph (from to &optional justify 255(defun fill-region-as-paragraph (from to &optional justify
251 nosqueeze squeeze-after) 256 nosqueeze squeeze-after)
252 "Fill the region as one paragraph. 257 "Fill the region as one paragraph.
@@ -421,14 +426,17 @@ space does not end a sentence, so don't break a line there."
421 ;; further fills will assume it ends a sentence. 426 ;; further fills will assume it ends a sentence.
422 ;; If we now know it does not end a sentence, 427 ;; If we now know it does not end a sentence,
423 ;; avoid putting it at the end of the line. 428 ;; avoid putting it at the end of the line.
424 (if sentence-end-double-space 429 (while (or (and sentence-end-double-space
425 (while (and (> (point) (+ linebeg 2)) 430 (> (point) (+ linebeg 2))
426 (eq (preceding-char) ?\ ) 431 (eq (preceding-char) ?\ )
427 (not (eq (following-char) ?\ )) 432 (not (eq (following-char) ?\ ))
428 (eq (char-after (- (point) 2)) ?\.)) 433 (eq (char-after (- (point) 2)) ?\.)
429 (forward-char -2) 434 (progn (forward-char -2) t))
430 (if (re-search-backward " \\|\\c|.\\|.\\c|" linebeg 0) 435 (and fill-nobreak-predicate
431 (forward-char 1)))) 436 (funcall fill-nobreak-predicate)
437 (goto-char (match-beginning 0))))
438 (if (re-search-backward " \\|\\c|.\\|.\\c|" linebeg 0)
439 (forward-char 1)))
432 ;; If the left margin and fill prefix by themselves 440 ;; If the left margin and fill prefix by themselves
433 ;; pass the fill-column. or if they are zero 441 ;; pass the fill-column. or if they are zero
434 ;; but we have no room for even one word, 442 ;; but we have no room for even one word,
@@ -450,7 +458,9 @@ space does not end a sentence, so don't break a line there."
450 sentence-end-double-space 458 sentence-end-double-space
451 (save-excursion (forward-char -1) 459 (save-excursion (forward-char -1)
452 (and (looking-at "\\. ") 460 (and (looking-at "\\. ")
453 (not (looking-at "\\. "))))))) 461 (not (looking-at "\\. ")))))
462 (and fill-nobreak-predicate
463 (funcall fill-nobreak-predicate))))
454 ;; Find a breakable point while ignoring the 464 ;; Find a breakable point while ignoring the
455 ;; following spaces. 465 ;; following spaces.
456 (skip-chars-forward " \t") 466 (skip-chars-forward " \t")
@@ -495,7 +505,9 @@ space does not end a sentence, so don't break a line there."
495 sentence-end-double-space 505 sentence-end-double-space
496 (save-excursion (forward-char -1) 506 (save-excursion (forward-char -1)
497 (and (looking-at "\\. ") 507 (and (looking-at "\\. ")
498 (not (looking-at "\\. "))))))) 508 (not (looking-at "\\. ")))))
509 (and fill-nobreak-predicate
510 (funcall fill-nobreak-predicate))))
499 ;; Find a breakable point while ignoring the 511 ;; Find a breakable point while ignoring the
500 ;; following spaces. 512 ;; following spaces.
501 (skip-chars-forward " \t") 513 (skip-chars-forward " \t")