# HG changeset patch # User Stefan Monnier # Date 1049324649 0 # Node ID 329ac267f1fcc0c20eef13e1e472fd8bf3d3f5b6 # Parent 41c0eed9d556dd95285f33fa13953186b4bc7574 (fill-region-as-paragraph): Remove obsolete `save-restriction'. Don't remove space at end of paragraph: it makes refill.el unusable. (fill-paragraph, fill-comment-paragraph): Don't add newline at EOP. diff -r 41c0eed9d556 -r 329ac267f1fc lisp/textmodes/fill.el --- a/lisp/textmodes/fill.el Wed Apr 02 21:38:43 2003 +0000 +++ b/lisp/textmodes/fill.el Wed Apr 02 23:04:09 2003 +0000 @@ -627,65 +627,61 @@ (string-match "\\`[ \t]*\\'" fill-prefix)) (setq fill-prefix nil))) - (save-restriction - (goto-char from) - (beginning-of-line) + (goto-char from) + (beginning-of-line) - (if (not justify) ; filling disabled: just check indentation - (progn - (goto-char from) - (while (< (point) to) - (if (and (not (eolp)) - (< (current-indentation) (current-left-margin))) - (fill-indent-to-left-margin)) - (forward-line 1))) + (if (not justify) ; filling disabled: just check indentation + (progn + (goto-char from) + (while (< (point) to) + (if (and (not (eolp)) + (< (current-indentation) (current-left-margin))) + (fill-indent-to-left-margin)) + (forward-line 1))) - (if use-hard-newlines - (remove-list-of-text-properties from to '(hard))) - ;; Make sure first line is indented (at least) to left margin... - (if (or (memq justify '(right center)) - (< (current-indentation) (current-left-margin))) - (fill-indent-to-left-margin)) - ;; Delete the fill-prefix from every line. - (fill-delete-prefix from to fill-prefix) - (setq from (point)) + (if use-hard-newlines + (remove-list-of-text-properties from to '(hard))) + ;; Make sure first line is indented (at least) to left margin... + (if (or (memq justify '(right center)) + (< (current-indentation) (current-left-margin))) + (fill-indent-to-left-margin)) + ;; Delete the fill-prefix from every line. + (fill-delete-prefix from to fill-prefix) + (setq from (point)) - ;; FROM, and point, are now before the text to fill, - ;; but after any fill prefix on the first line. + ;; FROM, and point, are now before the text to fill, + ;; but after any fill prefix on the first line. - (fill-delete-newlines from to justify nosqueeze squeeze-after) + (fill-delete-newlines from to justify nosqueeze squeeze-after) - ;; This is the actual filling loop. - (goto-char from) - (let (linebeg) - (while (< (point) to) - (setq linebeg (point)) - (move-to-column (1+ (current-fill-column))) - (if (when (< (point) to) - ;; Find the position where we'll break the line. - (fill-move-to-break-point linebeg) - ;; Check again to see if we got to the end of - ;; the paragraph. - (skip-chars-forward " \t") - (< (point) to)) - ;; Found a place to cut. - (progn - (fill-newline) - (when justify - ;; Justify the line just ended, if desired. - (save-excursion - (forward-line -1) - (justify-current-line justify nil t)))) + ;; This is the actual filling loop. + (goto-char from) + (let (linebeg) + (while (< (point) to) + (setq linebeg (point)) + (move-to-column (1+ (current-fill-column))) + (if (when (< (point) to) + ;; Find the position where we'll break the line. + (fill-move-to-break-point linebeg) + ;; Check again to see if we got to the end of + ;; the paragraph. + (skip-chars-forward " \t") + (< (point) to)) + ;; Found a place to cut. + (progn + (fill-newline) + (when justify + ;; Justify the line just ended, if desired. + (save-excursion + (forward-line -1) + (justify-current-line justify nil t)))) - (goto-char to) - (if (and (eolp) (or (not nosqueeze) justify)) - (delete-horizontal-space)) - ;; Justify this last line, if desired. - (if justify (justify-current-line justify t t)))))) - ;; Leave point after final newline. - (goto-char to)) - (unless (eobp) - (forward-char 1)) + (goto-char to) + ;; Justify this last line, if desired. + (if justify (justify-current-line justify t t)))))) + ;; Leave point after final newline. + (goto-char to) + (unless (eobp) (forward-char 1)) ;; Return the fill-prefix we used fill-prefix))) @@ -748,7 +744,6 @@ (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) @@ -828,19 +823,14 @@ (paragraph-ignore-fill-prefix nil) (fill-prefix comment-fill-prefix) (after-line (if has-code-and-comment - (line-beginning-position 2))) - ) - (setq end (progn - (forward-paragraph) - (or (bolp) (newline 1)) - (point))) + (line-beginning-position 2)))) + (setq end (progn (forward-paragraph) (point))) ;; If this comment starts on a line with code, ;; include that line in the filling. (setq beg (progn (backward-paragraph) (if (eq (point) after-line) (forward-line -1)) - (point)))) - ) + (point))))) ;; Find the fill-prefix to use. (cond