diff options
| author | Stefan Monnier | 2003-05-30 18:28:16 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-05-30 18:28:16 +0000 |
| commit | ad2feb08904628531585213bb77036befe9a2db2 (patch) | |
| tree | ba3687e2295878e24adb98afab17f64a0cca7ee6 | |
| parent | aba7ce7740c06a33789322ab664a03638d549aff (diff) | |
| download | emacs-ad2feb08904628531585213bb77036befe9a2db2.tar.gz emacs-ad2feb08904628531585213bb77036befe9a2db2.zip | |
(refill-adjust-ignorable-overlay): Don't hardcode pint-min == 1.
(refill-fill-paragraph-at): Use a more robust method to detect
when the paragraph is after point. Remove unused var `fill-pfx'.
| -rw-r--r-- | lisp/textmodes/refill.el | 82 |
1 files changed, 39 insertions, 43 deletions
diff --git a/lisp/textmodes/refill.el b/lisp/textmodes/refill.el index 4d5d6db35c4..b5dd64a891a 100644 --- a/lisp/textmodes/refill.el +++ b/lisp/textmodes/refill.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; refill.el --- `auto-fill' by refilling paragraphs on changes | 1 | ;;; refill.el --- `auto-fill' by refilling paragraphs on changes |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2000 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2000, 2003 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Dave Love <fx@gnu.org> | 5 | ;; Author: Dave Love <fx@gnu.org> |
| 6 | ;; Keywords: wp | 6 | ;; Keywords: wp |
| @@ -101,53 +101,49 @@ This is used to optimize refilling.") | |||
| 101 | (forward-line -1) | 101 | (forward-line -1) |
| 102 | (if (<= (point) (overlay-start overlay)) | 102 | (if (<= (point) (overlay-start overlay)) |
| 103 | ;; Just get OVERLAY out of the way | 103 | ;; Just get OVERLAY out of the way |
| 104 | (move-overlay overlay 1 1) | 104 | (move-overlay overlay (point-min) (point-min)) |
| 105 | ;; Make overlay contain only the region | 105 | ;; Make overlay contain only the region |
| 106 | (move-overlay overlay (overlay-start overlay) (point)))))) | 106 | (move-overlay overlay (overlay-start overlay) (point)))))) |
| 107 | 107 | ||
| 108 | (defun refill-fill-paragraph-at (pos &optional arg) | 108 | (defun refill-fill-paragraph-at (pos &optional arg) |
| 109 | "Like `fill-paragraph' at POS, but don't delete whitespace at paragraph end." | 109 | "Like `fill-paragraph' at POS, but don't delete whitespace at paragraph end." |
| 110 | (let (fill-pfx) | 110 | (save-excursion |
| 111 | (save-excursion | 111 | (goto-char pos) |
| 112 | (goto-char pos) | 112 | ;; FIXME: forward-paragraph seems to disregard `use-hard-newlines', |
| 113 | (unless (or (and (bolp) (eolp)) | 113 | ;; leading to excessive refilling and wrong choice of fill-prefix. |
| 114 | (save-match-data (looking-at "\n\n"))) | 114 | ;; might be a bug in my paragraphs.el. |
| 115 | ;; FIXME: forward-paragraph seems to disregard `use-hard-newlines', | 115 | (forward-paragraph) |
| 116 | ;; leading to excessive refilling and wrong choice of fill-prefix. | 116 | (skip-syntax-backward "-") |
| 117 | ;; might be a bug in my paragraphs.el. | 117 | (let ((end (point)) |
| 118 | (forward-paragraph) | 118 | (beg (progn (backward-paragraph) (point))) |
| 119 | (skip-syntax-backward "-") | 119 | (obeg (overlay-start refill-ignorable-overlay)) |
| 120 | (let ((end (point)) | 120 | (oend (overlay-end refill-ignorable-overlay))) |
| 121 | (beg (progn (backward-paragraph) (point))) | 121 | (unless (> beg pos) ;Don't fill if point is outside the paragraph. |
| 122 | (obeg (overlay-start refill-ignorable-overlay)) | 122 | (goto-char pos) |
| 123 | (oend (overlay-end refill-ignorable-overlay))) | 123 | (if (and (>= beg obeg) (< beg oend)) |
| 124 | (goto-char pos) | 124 | ;; Limit filling to the modified tail of the paragraph. |
| 125 | (if (and (>= beg obeg) (< beg oend)) | 125 | (let ( ;; When adaptive-fill-mode is enabled, the filling |
| 126 | ;; Limit filling to the modified tail of the paragraph. | 126 | ;; functions will attempt to set the fill prefix from |
| 127 | (let ( ;; When adaptive-fill-mode is enabled, the filling | 127 | ;; the fake paragraph bounds we pass in, so set it |
| 128 | ;; functions will attempt to set the fill prefix from | 128 | ;; ourselves first, using the real paragraph bounds. |
| 129 | ;; the fake paragraph bounds we pass in, so set it | 129 | (fill-prefix |
| 130 | ;; ourselves first, using the real paragraph bounds. | 130 | (if (and adaptive-fill-mode |
| 131 | (fill-prefix | 131 | (or (null fill-prefix) (string= fill-prefix ""))) |
| 132 | (if (and adaptive-fill-mode | 132 | (fill-context-prefix beg end) |
| 133 | (or (null fill-prefix) (string= fill-prefix ""))) | 133 | fill-prefix)) |
| 134 | (fill-context-prefix beg end) | 134 | ;; Turn off adaptive-fill-mode temporarily |
| 135 | fill-prefix)) | 135 | (adaptive-fill-mode nil)) |
| 136 | ;; Turn off adaptive-fill-mode temporarily | 136 | (save-restriction |
| 137 | (adaptive-fill-mode nil)) | 137 | (if use-hard-newlines |
| 138 | (save-restriction | 138 | (fill-region oend end arg) |
| 139 | (if use-hard-newlines | 139 | (fill-region-as-paragraph oend end arg))) |
| 140 | (fill-region oend end arg) | 140 | (move-overlay refill-ignorable-overlay obeg (point))) |
| 141 | (fill-region-as-paragraph oend end arg))) | 141 | ;; Fill the whole paragraph |
| 142 | (setq fill-pfx fill-prefix) | 142 | (save-restriction |
| 143 | (move-overlay refill-ignorable-overlay obeg (point))) | 143 | (if use-hard-newlines |
| 144 | ;; Fill the whole paragraph | 144 | (fill-region beg end arg) |
| 145 | (setq fill-pfx | 145 | (fill-region-as-paragraph beg end arg))) |
| 146 | (save-restriction | 146 | (move-overlay refill-ignorable-overlay beg (point))))))) |
| 147 | (if use-hard-newlines | ||
| 148 | (fill-region beg end arg) | ||
| 149 | (fill-region-as-paragraph beg end arg)))) | ||
| 150 | (move-overlay refill-ignorable-overlay beg (point)))))))) | ||
| 151 | 147 | ||
| 152 | (defun refill-fill-paragraph (arg) | 148 | (defun refill-fill-paragraph (arg) |
| 153 | "Like `fill-paragraph' but don't delete whitespace at paragraph end." | 149 | "Like `fill-paragraph' but don't delete whitespace at paragraph end." |