A line which `paragraph-start' matches either separates paragraphs
\(if `paragraph-separate' matches it also) or is the first line of a paragraph.
A paragraph end is the beginning of a line which is not part of the paragraph
-to which the end of the previous line belongs, or the end of the buffer."
+to which the end of the previous line belongs, or the end of the buffer.
+Returns the count of paragraphs left to move."
(interactive "p")
(or arg (setq arg 1))
(let* ((opoint (point))
(if (and (not (looking-at parsep))
(re-search-backward "^\n" (max (1- (point)) (point-min)) t)
(looking-at parsep))
- nil
+ (setq arg (1+ arg))
(setq start (point))
;; Move back over paragraph-separating lines.
(forward-char -1) (beginning-of-line)
(forward-line -1))
(if (bobp)
nil
+ (setq arg (1+ arg))
;; Go to end of the previous (non-separating) line.
(end-of-line)
;; Search back for line that starts or separates paragraphs.
(setq found-start nil)
(goto-char start))
found-start)
- ;; Found one.
- (progn
+ ;; Found one.
+ (progn
;; Move forward over paragraph separators.
;; We know this cannot reach the place we started
;; because we know we moved back over a non-separator.
(if (not (bolp))
(forward-line 1))))
;; No starter or separator line => use buffer beg.
- (goto-char (point-min)))))
- (setq arg (1+ arg)))
+ (goto-char (point-min))))))
(while (and (> arg 0) (not (eobp)))
- ;; Move forward over separator lines, and one more line.
- (while (prog1 (and (not (eobp))
- (progn (move-to-left-margin) (not (eobp)))
- (looking-at parsep))
- (forward-line 1)))
+ ;; Move forward over separator lines...
+ (while (and (not (eobp))
+ (progn (move-to-left-margin) (not (eobp)))
+ (looking-at parsep))
+ (forward-line 1))
+ (unless (eobp) (setq arg (1- arg)))
+ ;; ... and one more line.
+ (forward-line 1)
(if fill-prefix-regexp
;; There is a fill prefix; it overrides parstart.
(while (and (not (eobp))
(not (get-text-property (1- start) 'hard)))))
(forward-char 1))
(if (< (point) (point-max))
- (goto-char start)))
- (setq arg (1- arg)))
+ (goto-char start))))
(constrain-to-field nil opoint t)
;; Return the number of steps that could not be done.
arg))