43 |
|
|
44 |
Prefix argument says to turn mode on if positive, off if negative. |
Prefix argument says to turn mode on if positive, off if negative. |
45 |
When the mode is turned on, if there are newlines in the buffer but no hard |
When the mode is turned on, if there are newlines in the buffer but no hard |
46 |
newlines, ask the user whether to mark as hard any newlines preceeding a |
newlines, ask the user whether to mark as hard any newlines preceeding a |
47 |
`paragraph-start' line. From a program, second arg INSERT specifies whether |
`paragraph-start' line. From a program, second arg INSERT specifies whether |
48 |
to do this; it can be `never' to change nothing, t or `always' to force |
to do this; it can be `never' to change nothing, t or `always' to force |
49 |
marking, `guess' to try to do the right thing with no questions, nil |
marking, `guess' to try to do the right thing with no questions, nil |
50 |
or anything else to ask the user. |
or anything else to ask the user. |
51 |
|
|
52 |
Newlines not marked hard are called \"soft\", and are always internal |
Newlines not marked hard are called \"soft\", and are always internal |
53 |
to paragraphs. The fill functions insert and delete only soft newlines." |
to paragraphs. The fill functions insert and delete only soft newlines." |
54 |
|
:group 'paragraphs |
55 |
:extra-args (insert) |
:extra-args (insert) |
56 |
(when use-hard-newlines |
(when use-hard-newlines |
57 |
;; Turn mode on |
;; Turn mode on |
137 |
;; This is a bit stupid since it's not auto-updated when the |
;; This is a bit stupid since it's not auto-updated when the |
138 |
;; other variables are changes, but it's still useful info. |
;; other variables are changes, but it's still useful info. |
139 |
(concat (if sentence-end-without-period "\\w \\|") |
(concat (if sentence-end-without-period "\\w \\|") |
140 |
"[.?!][]\"')}]*" |
"[.?!$B!#!%!)!*$A!##.#?#!$(0!$!%!)!*$(G!$!%!)!*(B][]\"')}]*" |
141 |
(if sentence-end-double-space |
(if sentence-end-double-space |
142 |
"\\($\\| $\\|\t\\| \\)" "\\($\\|[\t ]\\)") |
"\\($\\| $\\|\t\\| \\)" "\\($\\|[\t ]\\)") |
143 |
"[ \t\n]*")) |
"[ \t\n]*")) |
174 |
A line which `paragraph-start' matches either separates paragraphs |
A line which `paragraph-start' matches either separates paragraphs |
175 |
\(if `paragraph-separate' matches it also) or is the first line of a paragraph. |
\(if `paragraph-separate' matches it also) or is the first line of a paragraph. |
176 |
A paragraph end is the beginning of a line which is not part of the paragraph |
A paragraph end is the beginning of a line which is not part of the paragraph |
177 |
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. |
178 |
|
Returns the count of paragraphs left to move." |
179 |
(interactive "p") |
(interactive "p") |
180 |
(or arg (setq arg 1)) |
(or arg (setq arg 1)) |
181 |
(let* ((opoint (point)) |
(let* ((opoint (point)) |
208 |
(if (and (not (looking-at parsep)) |
(if (and (not (looking-at parsep)) |
209 |
(re-search-backward "^\n" (max (1- (point)) (point-min)) t) |
(re-search-backward "^\n" (max (1- (point)) (point-min)) t) |
210 |
(looking-at parsep)) |
(looking-at parsep)) |
211 |
nil |
(setq arg (1+ arg)) |
212 |
(setq start (point)) |
(setq start (point)) |
213 |
;; Move back over paragraph-separating lines. |
;; Move back over paragraph-separating lines. |
214 |
(forward-char -1) (beginning-of-line) |
(forward-char -1) (beginning-of-line) |
218 |
(forward-line -1)) |
(forward-line -1)) |
219 |
(if (bobp) |
(if (bobp) |
220 |
nil |
nil |
221 |
|
(setq arg (1+ arg)) |
222 |
;; Go to end of the previous (non-separating) line. |
;; Go to end of the previous (non-separating) line. |
223 |
(end-of-line) |
(end-of-line) |
224 |
;; Search back for line that starts or separates paragraphs. |
;; Search back for line that starts or separates paragraphs. |
256 |
(setq found-start nil) |
(setq found-start nil) |
257 |
(goto-char start)) |
(goto-char start)) |
258 |
found-start) |
found-start) |
259 |
;; Found one. |
;; Found one. |
260 |
(progn |
(progn |
261 |
;; Move forward over paragraph separators. |
;; Move forward over paragraph separators. |
262 |
;; We know this cannot reach the place we started |
;; We know this cannot reach the place we started |
263 |
;; because we know we moved back over a non-separator. |
;; because we know we moved back over a non-separator. |
273 |
(if (not (bolp)) |
(if (not (bolp)) |
274 |
(forward-line 1)))) |
(forward-line 1)))) |
275 |
;; No starter or separator line => use buffer beg. |
;; No starter or separator line => use buffer beg. |
276 |
(goto-char (point-min))))) |
(goto-char (point-min)))))) |
|
(setq arg (1+ arg))) |
|
277 |
|
|
278 |
(while (and (> arg 0) (not (eobp))) |
(while (and (> arg 0) (not (eobp))) |
279 |
;; Move forward over separator lines, and one more line. |
;; Move forward over separator lines... |
280 |
(while (prog1 (and (not (eobp)) |
(while (and (not (eobp)) |
281 |
(progn (move-to-left-margin) (not (eobp))) |
(progn (move-to-left-margin) (not (eobp))) |
282 |
(looking-at parsep)) |
(looking-at parsep)) |
283 |
(forward-line 1))) |
(forward-line 1)) |
284 |
|
(unless (eobp) (setq arg (1- arg))) |
285 |
|
;; ... and one more line. |
286 |
|
(forward-line 1) |
287 |
(if fill-prefix-regexp |
(if fill-prefix-regexp |
288 |
;; There is a fill prefix; it overrides parstart. |
;; There is a fill prefix; it overrides parstart. |
289 |
(while (and (not (eobp)) |
(while (and (not (eobp)) |
302 |
(not (get-text-property (1- start) 'hard))))) |
(not (get-text-property (1- start) 'hard))))) |
303 |
(forward-char 1)) |
(forward-char 1)) |
304 |
(if (< (point) (point-max)) |
(if (< (point) (point-max)) |
305 |
(goto-char start))) |
(goto-char start)))) |
306 |
(setq arg (1- arg))) |
(constrain-to-field nil opoint t) |
307 |
(constrain-to-field nil opoint t))) |
;; Return the number of steps that could not be done. |
308 |
|
arg)) |
309 |
|
|
310 |
(defun backward-paragraph (&optional arg) |
(defun backward-paragraph (&optional arg) |
311 |
"Move backward to start of paragraph. |
"Move backward to start of paragraph. |
457 |
(interactive "*p") |
(interactive "*p") |
458 |
(transpose-subr 'forward-sentence arg)) |
(transpose-subr 'forward-sentence arg)) |
459 |
|
|
460 |
|
;;; Local Variables: |
461 |
|
;;; coding: iso-2022-7bit |
462 |
|
;;; End: |
463 |
|
|
464 |
;;; paragraphs.el ends here |
;;; paragraphs.el ends here |