aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-02-02 09:50:23 +0000
committerRichard M. Stallman1995-02-02 09:50:23 +0000
commit86dfb30a1b80ffa3ef43581cb3f1bfe167a9dce7 (patch)
treee0654af2bcf63937b13c91f8c52b5e1c808b578c
parentfcf9745f68a7c86ec490f84435bc984f683e2747 (diff)
downloademacs-86dfb30a1b80ffa3ef43581cb3f1bfe167a9dce7.tar.gz
emacs-86dfb30a1b80ffa3ef43581cb3f1bfe167a9dce7.zip
(fill-paragraph-function): New variable.
(fill-paragraph): Use it.
-rw-r--r--lisp/textmodes/fill.el34
1 files changed, 21 insertions, 13 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 13c2ab3c080..79714d91c1c 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -37,6 +37,9 @@ A value of nil means that any change in indentation starts a new paragraph.")
37(defconst sentence-end-double-space t 37(defconst sentence-end-double-space t
38 "*Non-nil means a single space does not end a sentence.") 38 "*Non-nil means a single space does not end a sentence.")
39 39
40(defvar fill-paragraph-function nil
41 "Mode-specific function to fill a paragraph.")
42
40(defun set-fill-prefix () 43(defun set-fill-prefix ()
41 "Set the fill prefix to the current line up to point. 44 "Set the fill prefix to the current line up to point.
42Filling expects lines to start with the fill prefix and 45Filling expects lines to start with the fill prefix and
@@ -317,20 +320,25 @@ space does not end a sentence, so don't break a line there."
317(defun fill-paragraph (arg) 320(defun fill-paragraph (arg)
318 "Fill paragraph at or after point. Prefix arg means justify as well. 321 "Fill paragraph at or after point. Prefix arg means justify as well.
319If `sentence-end-double-space' is non-nil, then period followed by one 322If `sentence-end-double-space' is non-nil, then period followed by one
320space does not end a sentence, so don't break a line there." 323space does not end a sentence, so don't break a line there.
324
325If `fill-paragraph-function' is non-nil, we call it (passing our
326argument to it), and if it returns non-nil, we simply return its value."
321 (interactive "P") 327 (interactive "P")
322 (let ((before (point))) 328 (or (and fill-paragraph-function
323 (save-excursion 329 (funcall fill-paragraph-function arg))
324 (forward-paragraph) 330 (let ((before (point)))
325 (or (bolp) (newline 1)) 331 (save-excursion
326 (let ((end (point)) 332 (forward-paragraph)
327 (beg (progn (backward-paragraph) (point)))) 333 (or (bolp) (newline 1))
328 (goto-char before) 334 (let ((end (point))
329 (if use-hard-newlines 335 (beg (progn (backward-paragraph) (point))))
330 ;; Can't use fill-region-as-paragraph, since this paragraph may 336 (goto-char before)
331 ;; still contain hard newlines. See fill-region. 337 (if use-hard-newlines
332 (fill-region beg end arg) 338 ;; Can't use fill-region-as-paragraph, since this paragraph may
333 (fill-region-as-paragraph beg end arg)))))) 339 ;; still contain hard newlines. See fill-region.
340 (fill-region beg end arg)
341 (fill-region-as-paragraph beg end arg)))))))
334 342
335(defun fill-region (from to &optional justify nosqueeze to-eop) 343(defun fill-region (from to &optional justify nosqueeze to-eop)
336 "Fill each of the paragraphs in the region. 344 "Fill each of the paragraphs in the region.