aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-01-16 19:05:39 +0000
committerRichard M. Stallman1994-01-16 19:05:39 +0000
commit8a2a4ced7a623389aa4c82d348756fbe4f0c0fd4 (patch)
treea8d6f1394720385492b4ce0d9b9c664756636163
parentdace61c11f4ae00b9baf96839846fde3fb733f7f (diff)
downloademacs-8a2a4ced7a623389aa4c82d348756fbe4f0c0fd4.tar.gz
emacs-8a2a4ced7a623389aa4c82d348756fbe4f0c0fd4.zip
(forward-paragraph): If moving back we find nothing
but separator lines till buffer beg, just stay there. Exit outer loop if at beg or end of buffer.
-rw-r--r--lisp/textmodes/paragraphs.el51
1 files changed, 29 insertions, 22 deletions
diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el
index c6885617015..fd5edc09a7e 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -75,35 +75,42 @@ to which the end of the previous line belongs, or the end of the buffer."
75 (concat paragraph-separate "\\|^" 75 (concat paragraph-separate "\\|^"
76 fill-prefix-regexp "[ \t]*$") 76 fill-prefix-regexp "[ \t]*$")
77 paragraph-separate))) 77 paragraph-separate)))
78 (while (< arg 0) 78 (while (and (< arg 0) (not (bobp)))
79 (if (and (not (looking-at paragraph-separate)) 79 (if (and (not (looking-at paragraph-separate))
80 (re-search-backward "^\n" (max (1- (point)) (point-min)) t)) 80 (re-search-backward "^\n" (max (1- (point)) (point-min)) t))
81 nil 81 nil
82 ;; Move back over paragraph-separating lines.
82 (forward-char -1) (beginning-of-line) 83 (forward-char -1) (beginning-of-line)
83 (while (and (not (bobp)) (looking-at paragraph-separate)) 84 (while (and (not (bobp)) (looking-at paragraph-separate))
84 (forward-line -1)) 85 (forward-line -1))
85 (end-of-line) 86 (if (bobp)
86 ;; Search back for line that starts or separates paragraphs. 87 nil
87 (if (if fill-prefix-regexp 88 ;; Go to end of the previous (non-separating) line.
88 ;; There is a fill prefix; it overrides paragraph-start. 89 (end-of-line)
89 (progn 90 ;; Search back for line that starts or separates paragraphs.
90 (while (progn (beginning-of-line) 91 (if (if fill-prefix-regexp
91 (and (not (bobp)) 92 ;; There is a fill prefix; it overrides paragraph-start.
92 (not (looking-at paragraph-separate)) 93 (progn
93 (looking-at fill-prefix-regexp))) 94 (while (progn (beginning-of-line)
94 (forward-line -1)) 95 (and (not (bobp))
95 (not (bobp))) 96 (not (looking-at paragraph-separate))
96 (re-search-backward paragraph-start nil t)) 97 (looking-at fill-prefix-regexp)))
97 ;; Found one. 98 (forward-line -1))
98 (progn 99 (not (bobp)))
99 (while (and (not (eobp)) (looking-at paragraph-separate)) 100 (re-search-backward paragraph-start nil t))
100 (forward-line 1)) 101 ;; Found one.
101 (if (eq (char-after (- (point) 2)) ?\n) 102 (progn
102 (forward-line -1))) 103 ;; Move forward over paragraph separators.
103 ;; No starter or separator line => use buffer beg. 104 ;; We know this cannot reach the place we started
104 (goto-char (point-min)))) 105 ;; because we know we moved back over a non-separator.
106 (while (and (not (eobp)) (looking-at paragraph-separate))
107 (forward-line 1))
108 (if (eq (char-after (- (point) 2)) ?\n)
109 (forward-line -1)))
110 ;; No starter or separator line => use buffer beg.
111 (goto-char (point-min)))))
105 (setq arg (1+ arg))) 112 (setq arg (1+ arg)))
106 (while (> arg 0) 113 (while (and (> arg 0) (not (eobp)))
107 (beginning-of-line) 114 (beginning-of-line)
108 (while (prog1 (and (not (eobp)) 115 (while (prog1 (and (not (eobp))
109 (looking-at paragraph-separate)) 116 (looking-at paragraph-separate))