summaryrefslogtreecommitdiff
path: root/lisp/textmodes/refill.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2003-05-30 18:28:16 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2003-05-30 18:28:16 +0000
commitad2feb08904628531585213bb77036befe9a2db2 (patch)
treeba3687e2295878e24adb98afab17f64a0cca7ee6 /lisp/textmodes/refill.el
parentaba7ce7740c06a33789322ab664a03638d549aff (diff)
downloademacs-ad2feb08904628531585213bb77036befe9a2db2.tar.gz
(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'.
Diffstat (limited to 'lisp/textmodes/refill.el')
-rw-r--r--lisp/textmodes/refill.el82
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 @@
;;; refill.el --- `auto-fill' by refilling paragraphs on changes
-;; Copyright (C) 2000 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2003 Free Software Foundation, Inc.
;; Author: Dave Love <fx@gnu.org>
;; Keywords: wp
@@ -101,53 +101,49 @@ This is used to optimize refilling.")
(forward-line -1)
(if (<= (point) (overlay-start overlay))
;; Just get OVERLAY out of the way
- (move-overlay overlay 1 1)
+ (move-overlay overlay (point-min) (point-min))
;; Make overlay contain only the region
(move-overlay overlay (overlay-start overlay) (point))))))
(defun refill-fill-paragraph-at (pos &optional arg)
"Like `fill-paragraph' at POS, but don't delete whitespace at paragraph end."
- (let (fill-pfx)
- (save-excursion
- (goto-char pos)
- (unless (or (and (bolp) (eolp))
- (save-match-data (looking-at "\n\n")))
- ;; FIXME: forward-paragraph seems to disregard `use-hard-newlines',
- ;; leading to excessive refilling and wrong choice of fill-prefix.
- ;; might be a bug in my paragraphs.el.
- (forward-paragraph)
- (skip-syntax-backward "-")
- (let ((end (point))
- (beg (progn (backward-paragraph) (point)))
- (obeg (overlay-start refill-ignorable-overlay))
- (oend (overlay-end refill-ignorable-overlay)))
- (goto-char pos)
- (if (and (>= beg obeg) (< beg oend))
- ;; Limit filling to the modified tail of the paragraph.
- (let ( ;; When adaptive-fill-mode is enabled, the filling
- ;; functions will attempt to set the fill prefix from
- ;; the fake paragraph bounds we pass in, so set it
- ;; ourselves first, using the real paragraph bounds.
- (fill-prefix
- (if (and adaptive-fill-mode
- (or (null fill-prefix) (string= fill-prefix "")))
- (fill-context-prefix beg end)
- fill-prefix))
- ;; Turn off adaptive-fill-mode temporarily
- (adaptive-fill-mode nil))
- (save-restriction
- (if use-hard-newlines
- (fill-region oend end arg)
- (fill-region-as-paragraph oend end arg)))
- (setq fill-pfx fill-prefix)
- (move-overlay refill-ignorable-overlay obeg (point)))
- ;; Fill the whole paragraph
- (setq fill-pfx
- (save-restriction
- (if use-hard-newlines
- (fill-region beg end arg)
- (fill-region-as-paragraph beg end arg))))
- (move-overlay refill-ignorable-overlay beg (point))))))))
+ (save-excursion
+ (goto-char pos)
+ ;; FIXME: forward-paragraph seems to disregard `use-hard-newlines',
+ ;; leading to excessive refilling and wrong choice of fill-prefix.
+ ;; might be a bug in my paragraphs.el.
+ (forward-paragraph)
+ (skip-syntax-backward "-")
+ (let ((end (point))
+ (beg (progn (backward-paragraph) (point)))
+ (obeg (overlay-start refill-ignorable-overlay))
+ (oend (overlay-end refill-ignorable-overlay)))
+ (unless (> beg pos) ;Don't fill if point is outside the paragraph.
+ (goto-char pos)
+ (if (and (>= beg obeg) (< beg oend))
+ ;; Limit filling to the modified tail of the paragraph.
+ (let ( ;; When adaptive-fill-mode is enabled, the filling
+ ;; functions will attempt to set the fill prefix from
+ ;; the fake paragraph bounds we pass in, so set it
+ ;; ourselves first, using the real paragraph bounds.
+ (fill-prefix
+ (if (and adaptive-fill-mode
+ (or (null fill-prefix) (string= fill-prefix "")))
+ (fill-context-prefix beg end)
+ fill-prefix))
+ ;; Turn off adaptive-fill-mode temporarily
+ (adaptive-fill-mode nil))
+ (save-restriction
+ (if use-hard-newlines
+ (fill-region oend end arg)
+ (fill-region-as-paragraph oend end arg)))
+ (move-overlay refill-ignorable-overlay obeg (point)))
+ ;; Fill the whole paragraph
+ (save-restriction
+ (if use-hard-newlines
+ (fill-region beg end arg)
+ (fill-region-as-paragraph beg end arg)))
+ (move-overlay refill-ignorable-overlay beg (point)))))))
(defun refill-fill-paragraph (arg)
"Like `fill-paragraph' but don't delete whitespace at paragraph end."