comparison lisp/textmodes/refill.el @ 51292:c41cc5ded813

(refill-fill-paragraph-at): Avoid refilling the following paragraph. (refill-doit): Doc fix.
author Richard M. Stallman <rms@gnu.org>
date Wed, 28 May 2003 11:30:48 +0000
parents 6fe4a9da704f
children 816e3b31173a
comparison
equal deleted inserted replaced
51291:304ec2e5804c 51292:c41cc5ded813
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 (let (fill-pfx)
111 (save-excursion 111 (save-excursion
112 (goto-char pos) 112 (goto-char pos)
113 ;; FIXME: forward-paragraph seems to disregard `use-hard-newlines', 113 (unless (or (and (bolp) (eolp))
114 ;; leading to excessive refilling and wrong choice of fill-prefix. 114 (save-match-data (looking-at "\n\n")))
115 ;; might be a bug in my paragraphs.el. 115 ;; FIXME: forward-paragraph seems to disregard `use-hard-newlines',
116 (forward-paragraph) 116 ;; leading to excessive refilling and wrong choice of fill-prefix.
117 (skip-syntax-backward "-") 117 ;; might be a bug in my paragraphs.el.
118 (let ((end (point)) 118 (forward-paragraph)
119 (beg (progn (backward-paragraph) (point))) 119 (skip-syntax-backward "-")
120 (obeg (overlay-start refill-ignorable-overlay)) 120 (let ((end (point))
121 (oend (overlay-end refill-ignorable-overlay))) 121 (beg (progn (backward-paragraph) (point)))
122 (goto-char pos) 122 (obeg (overlay-start refill-ignorable-overlay))
123 (if (and (>= beg obeg) (< beg oend)) 123 (oend (overlay-end refill-ignorable-overlay)))
124 ;; Limit filling to the modified tail of the paragraph. 124 (goto-char pos)
125 (let (;; When adaptive-fill-mode is enabled, the filling 125 (if (and (>= beg obeg) (< beg oend))
126 ;; functions will attempt to set the fill prefix from 126 ;; Limit filling to the modified tail of the paragraph.
127 ;; the fake paragraph bounds we pass in, so set it 127 (let ( ;; When adaptive-fill-mode is enabled, the filling
128 ;; ourselves first, using the real paragraph bounds. 128 ;; functions will attempt to set the fill prefix from
129 (fill-prefix 129 ;; the fake paragraph bounds we pass in, so set it
130 (if (and adaptive-fill-mode 130 ;; ourselves first, using the real paragraph bounds.
131 (or (null fill-prefix) (string= fill-prefix ""))) 131 (fill-prefix
132 (fill-context-prefix beg end) 132 (if (and adaptive-fill-mode
133 fill-prefix)) 133 (or (null fill-prefix) (string= fill-prefix "")))
134 ;; Turn off adaptive-fill-mode temporarily 134 (fill-context-prefix beg end)
135 (adaptive-fill-mode nil)) 135 fill-prefix))
136 (save-restriction 136 ;; Turn off adaptive-fill-mode temporarily
137 (if use-hard-newlines 137 (adaptive-fill-mode nil))
138 (fill-region oend end arg)
139 (fill-region-as-paragraph oend end arg)))
140 (setq fill-pfx fill-prefix)
141 (move-overlay refill-ignorable-overlay obeg (point)))
142 ;; Fill the whole paragraph
143 (setq fill-pfx
144 (save-restriction 138 (save-restriction
145 (if use-hard-newlines 139 (if use-hard-newlines
146 (fill-region beg end arg) 140 (fill-region oend end arg)
147 (fill-region-as-paragraph beg end arg)))) 141 (fill-region-as-paragraph oend end arg)))
148 (move-overlay refill-ignorable-overlay beg (point))))))) 142 (setq fill-pfx fill-prefix)
143 (move-overlay refill-ignorable-overlay obeg (point)))
144 ;; Fill the whole paragraph
145 (setq fill-pfx
146 (save-restriction
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))))))))
149 151
150 (defun refill-fill-paragraph (arg) 152 (defun refill-fill-paragraph (arg)
151 "Like `fill-paragraph' but don't delete whitespace at paragraph end." 153 "Like `fill-paragraph' but don't delete whitespace at paragraph end."
152 (refill-fill-paragraph-at (point) arg)) 154 (refill-fill-paragraph-at (point) arg))
153 155
154 (defvar refill-doit nil 156 (defvar refill-doit nil
155 "Non-nil means that `refill-post-command-function' does its processing. 157 "Non-nil tells `refill-post-command-function' to do its processing.
156 Set by `refill-after-change-function' in `after-change-functions' and 158 Set by `refill-after-change-function' in `after-change-functions' and
157 unset by `refill-post-command-function' in `post-command-hook', and 159 unset by `refill-post-command-function' in `post-command-hook', and
158 sometimes `refill-pre-command-function' in `pre-command-hook'. This 160 sometimes `refill-pre-command-function' in `pre-command-hook'. This
159 ensures refilling is only done once per command that causes a change, 161 ensures refilling is only done once per command that causes a change,
160 regardless of the number of after-change calls from commands doing 162 regardless of the number of after-change calls from commands doing