]> git.eshelyaron.com Git - emacs.git/commitdiff
(fill-paragraph-function): New variable.
authorRichard M. Stallman <rms@gnu.org>
Thu, 2 Feb 1995 09:50:23 +0000 (09:50 +0000)
committerRichard M. Stallman <rms@gnu.org>
Thu, 2 Feb 1995 09:50:23 +0000 (09:50 +0000)
(fill-paragraph): Use it.

lisp/textmodes/fill.el

index 13c2ab3c080394f2ca14bd7c1eb8b0e2d268bd9b..79714d91c1c8cf5ce9247adf8b46f0284ea5ecfa 100644 (file)
@@ -37,6 +37,9 @@ A value of nil means that any change in indentation starts a new paragraph.")
 (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 @@ space does not end a sentence, so don't break a line there."
 (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.