changeset 47751:cd005e017b51

(fill-paragraph): Give up if there's no paragraph at or after point.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 03 Oct 2002 23:01:35 +0000
parents 75f4a9fc7b34
children 2d40dec1b2d0
files lisp/textmodes/fill.el
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/fill.el	Thu Oct 03 23:00:19 2002 +0000
+++ b/lisp/textmodes/fill.el	Thu Oct 03 23:01:35 2002 +0000
@@ -697,18 +697,20 @@
 	    ;; Fill prefix used for filling the paragraph.
 	    fill-pfx)
 	(save-excursion
-	  (forward-paragraph)
-	  (or (bolp) (newline 1))
-	  (let ((end (point))
-		(beg (progn (backward-paragraph) (point))))
-	    (goto-char before)
-	    (setq fill-pfx
-		  (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)))))
+	  (if (not (zerop (forward-paragraph)))
+	      ;; There's no paragraph at or after point: give up.
+	      (setq fill-pfx "")
+	    (or (bolp) (newline 1))
+	    (let ((end (point))
+		  (beg (progn (backward-paragraph) (point))))
+	      (goto-char before)
+	      (setq fill-pfx
+		    (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))))))
 	;; See if point ended up inside the fill-prefix, and if so, move
 	;; past it.
 	(skip-line-prefix fill-pfx)