changeset 10631:dc245bfecc3b

(fill-paragraph-function): New variable. (fill-paragraph): Use it.
author Richard M. Stallman <rms@gnu.org>
date Thu, 02 Feb 1995 09:50:23 +0000
parents 3e851e5cab1f
children 202c70b39c10
files lisp/textmodes/fill.el
diffstat 1 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/fill.el	Thu Feb 02 09:48:01 1995 +0000
+++ b/lisp/textmodes/fill.el	Thu Feb 02 09:50:23 1995 +0000
@@ -37,6 +37,9 @@
 (defconst sentence-end-double-space t
   "*Non-nil means a single space does not end a sentence.")
 
+(defvar fill-paragraph-function nil
+  "Mode-specific function to fill a paragraph.")
+
 (defun set-fill-prefix ()
   "Set the fill prefix to the current line up to point.
 Filling expects lines to start with the fill prefix and
@@ -317,20 +320,25 @@
 (defun fill-paragraph (arg)
   "Fill paragraph at or after point.  Prefix arg means justify as well.
 If `sentence-end-double-space' is non-nil, then period followed by one
-space does not end a sentence, so don't break a line there."
+space does not end a sentence, so don't break a line there.
+
+If `fill-paragraph-function' is non-nil, we call it (passing our
+argument to it), and if it returns non-nil, we simply return its value."
   (interactive "P")
-  (let ((before (point)))
-    (save-excursion
-      (forward-paragraph)
-      (or (bolp) (newline 1))
-      (let ((end (point))
-	    (beg (progn (backward-paragraph) (point))))
-	(goto-char before)
-	(if use-hard-newlines
-	    ;; Can't use fill-region-as-paragraph, since this paragraph may
-	    ;; still contain hard newlines.  See fill-region.
-	    (fill-region beg end arg)
-	  (fill-region-as-paragraph beg end arg))))))
+  (or (and fill-paragraph-function
+	   (funcall fill-paragraph-function arg))
+      (let ((before (point)))
+	(save-excursion
+	  (forward-paragraph)
+	  (or (bolp) (newline 1))
+	  (let ((end (point))
+		(beg (progn (backward-paragraph) (point))))
+	    (goto-char before)
+	    (if use-hard-newlines
+		;; Can't use fill-region-as-paragraph, since this paragraph may
+		;; still contain hard newlines.  See fill-region.
+		(fill-region beg end arg)
+	      (fill-region-as-paragraph beg end arg)))))))
 
 (defun fill-region (from to &optional justify nosqueeze to-eop)
   "Fill each of the paragraphs in the region.