diff options
| author | Richard M. Stallman | 1997-06-17 21:46:40 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-06-17 21:46:40 +0000 |
| commit | b5263b80d3e3eed205d0268b8dd13520ab6619a2 (patch) | |
| tree | dc28d564f8a8cd552b544d96997f0374a0471f81 | |
| parent | 32632f66779b17f7551173e6eed9b8355caf707f (diff) | |
| download | emacs-b5263b80d3e3eed205d0268b8dd13520ab6619a2.tar.gz emacs-b5263b80d3e3eed205d0268b8dd13520ab6619a2.zip | |
(fill-context-prefix): Fix criteria for first line,
and for second line; always fetch prefixes from both lines.
| -rw-r--r-- | lisp/textmodes/fill.el | 85 |
1 files changed, 50 insertions, 35 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index c3628be99f8..a769bd33616 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; fill.el --- fill commands for Emacs | 1 | ;;; fill.el --- fill commands for Emacs |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1985, 86, 92, 94, 95, 1996 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1985, 86, 92, 94, 95, 96, 1997 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Keywords: wp | 5 | ;; Keywords: wp |
| 6 | 6 | ||
| @@ -183,45 +183,60 @@ act as a paragraph-separator." | |||
| 183 | (if (eolp) (forward-line 1)) | 183 | (if (eolp) (forward-line 1)) |
| 184 | ;; Move to the second line unless there is just one. | 184 | ;; Move to the second line unless there is just one. |
| 185 | (let ((firstline (point)) | 185 | (let ((firstline (point)) |
| 186 | first-line-prefix | ||
| 186 | ;; Non-nil if we are on the second line. | 187 | ;; Non-nil if we are on the second line. |
| 187 | at-second | 188 | at-second |
| 188 | result) | 189 | second-line-prefix |
| 190 | start) | ||
| 191 | (move-to-left-margin) | ||
| 192 | (setq start (point)) | ||
| 193 | (setq first-line-prefix | ||
| 194 | (cond ((looking-at paragraph-start) nil) | ||
| 195 | ((and adaptive-fill-regexp (looking-at adaptive-fill-regexp)) | ||
| 196 | (buffer-substring-no-properties start (match-end 0))) | ||
| 197 | (adaptive-fill-function (funcall adaptive-fill-function)))) | ||
| 189 | (forward-line 1) | 198 | (forward-line 1) |
| 190 | (if (>= (point) to) | 199 | (if (>= (point) to) |
| 191 | (goto-char firstline) | 200 | (goto-char firstline) |
| 192 | (setq at-second t)) | 201 | (setq at-second t) |
| 193 | (move-to-left-margin) | 202 | (move-to-left-margin) |
| 194 | (let ((start (point))) | 203 | (setq start (point)) |
| 195 | (setq result | 204 | (setq second-line-prefix |
| 196 | (if (not (looking-at paragraph-start)) | 205 | (cond ((looking-at paragraph-start) nil) |
| 197 | (cond ((and adaptive-fill-regexp (looking-at adaptive-fill-regexp)) | 206 | ((and adaptive-fill-regexp (looking-at adaptive-fill-regexp)) |
| 198 | (buffer-substring-no-properties start (match-end 0))) | 207 | (buffer-substring-no-properties start (match-end 0))) |
| 199 | (adaptive-fill-function (funcall adaptive-fill-function))))) | 208 | (adaptive-fill-function (funcall adaptive-fill-function))))) |
| 200 | (if at-second | 209 | (if at-second |
| 201 | ;; If we get a fill prefix from the second line, | 210 | ;; If we get a fill prefix from the second line, |
| 202 | ;; make sure it's on the first line too. | 211 | ;; make sure it or something compatible is on the first line too. |
| 203 | (and result | 212 | (and second-line-prefix |
| 204 | (save-excursion | 213 | (if (or (string-match (regexp-quote second-line-prefix) |
| 205 | (forward-line -1) | 214 | first-line-prefix) |
| 206 | (if (looking-at (regexp-quote result)) | 215 | (and (string-match "[ \t]" second-line-prefix) |
| 207 | result))) | 216 | (>= (string-width first-line-prefix) |
| 208 | ;; If we get a fill prefix from a one-line paragraph, | 217 | (string-width second-line-prefix)))) |
| 209 | ;; maybe change it to whitespace, | 218 | second-line-prefix)) |
| 210 | ;; and check that it isn't a paragraph starter. | 219 | ;; If we get a fill prefix from a one-line paragraph, |
| 211 | (if result | 220 | ;; maybe change it to whitespace, |
| 212 | (progn | 221 | ;; and check that it isn't a paragraph starter. |
| 213 | ;; If RESULT comes from the first line, | 222 | (if first-line-prefix |
| 214 | ;; see if it seems reasonable to use for all lines. | 223 | (let ((result |
| 215 | ;; If not, replace it with whitespace. | 224 | ;; If first-line-prefix comes from the first line, |
| 216 | (or (and first-line-regexp | 225 | ;; see if it seems reasonable to use for all lines. |
| 217 | (string-match first-line-regexp result)) | 226 | ;; If not, replace it with whitespace. |
| 218 | (and comment-start-skip | 227 | (if (or (and first-line-regexp |
| 219 | (string-match comment-start-skip result)) | 228 | (string-match first-line-regexp |
| 220 | (setq result (make-string (string-width result) ?\ ))) | 229 | first-line-prefix)) |
| 221 | ;; But either way, reject it if it indicates | 230 | (and comment-start-skip |
| 222 | ;; the start of a paragraph. | 231 | (string-match comment-start-skip |
| 223 | (if (not (eq 0 (string-match paragraph-start result))) | 232 | first-line-prefix))) |
| 224 | result)))))))) | 233 | first-line-prefix |
| 234 | (make-string (string-width first-line-prefix) ?\ )))) | ||
| 235 | ;; But either way, reject it if it indicates the start | ||
| 236 | ;; of a paragraph when text follows it. | ||
| 237 | (if (not (eq 0 (string-match paragraph-start | ||
| 238 | (concat result "a")))) | ||
| 239 | result)))))))) | ||
| 225 | 240 | ||
| 226 | (defun fill-region-as-paragraph (from to &optional justify | 241 | (defun fill-region-as-paragraph (from to &optional justify |
| 227 | nosqueeze squeeze-after) | 242 | nosqueeze squeeze-after) |