comparison lisp/textmodes/refill.el @ 42263:ea39d5799d38

(refill-mode): Don't barf when redundantly turning refill-mode off.
author Miles Bader <miles@gnu.org>
date Sat, 22 Dec 2001 12:25:14 +0000
parents b27f7112ce6f
children 3f0b3e6d23fb
comparison
equal deleted inserted replaced
42262:546d14a7f305 42263:ea39d5799d38
220 220
221 When Refill mode is on, the current paragraph will be formatted when 221 When Refill mode is on, the current paragraph will be formatted when
222 changes are made within it. Self-inserting characters only cause 222 changes are made within it. Self-inserting characters only cause
223 refilling if they would cause auto-filling." 223 refilling if they would cause auto-filling."
224 nil " Refill" '(("\177" . backward-delete-char-untabify)) 224 nil " Refill" '(("\177" . backward-delete-char-untabify))
225 ;; This provides the test for recursive paragraph filling. 225 ;; Remove old state if necessary
226 (make-local-variable 'fill-paragraph-function) 226 (when refill-ignorable-overlay
227 (delete-overlay refill-ignorable-overlay)
228 (kill-local-variable 'refill-ignorable-overlay))
229 (when refill-late-fill-paragraph-function
230 (setq fill-paragraph-function refill-late-fill-paragraph-function)
231 (kill-local-variable 'refill-late-fill-paragraph-function))
227 (if refill-mode 232 (if refill-mode
228 (progn 233 (progn
229 (add-hook 'after-change-functions 'refill-after-change-function nil t) 234 (add-hook 'after-change-functions 'refill-after-change-function nil t)
230 (add-hook 'post-command-hook 'refill-post-command-function nil t) 235 (add-hook 'post-command-hook 'refill-post-command-function nil t)
231 (add-hook 'pre-command-hook 'refill-pre-command-function nil t) 236 (add-hook 'pre-command-hook 'refill-pre-command-function nil t)
232 (set (make-local-variable 'refill-late-fill-paragraph-function) 237 (set (make-local-variable 'refill-late-fill-paragraph-function)
233 fill-paragraph-function) 238 fill-paragraph-function)
239 ;; This provides the test for recursive paragraph filling.
234 (set (make-local-variable 'fill-paragraph-function) 240 (set (make-local-variable 'fill-paragraph-function)
235 'refill-fill-paragraph) 241 'refill-fill-paragraph)
236 ;; When using justification, doing DEL on 2 spaces should remove 242 ;; When using justification, doing DEL on 2 spaces should remove
237 ;; both, otherwise, the subsequent refill will undo the DEL. 243 ;; both, otherwise, the subsequent refill will undo the DEL.
238 (set (make-local-variable 'backward-delete-char-untabify-method) 244 (set (make-local-variable 'backward-delete-char-untabify-method)
243 (overlay-put refill-ignorable-overlay 'insert-behind-hooks 249 (overlay-put refill-ignorable-overlay 'insert-behind-hooks
244 '(refill-adjust-ignorable-overlay)) 250 '(refill-adjust-ignorable-overlay))
245 (auto-fill-mode 0)) 251 (auto-fill-mode 0))
246 (remove-hook 'after-change-functions 'refill-after-change-function t) 252 (remove-hook 'after-change-functions 'refill-after-change-function t)
247 (remove-hook 'post-command-hook 'refill-post-command-function t) 253 (remove-hook 'post-command-hook 'refill-post-command-function t)
248 (delete-overlay refill-ignorable-overlay)
249 (setq fill-paragraph-function refill-late-fill-paragraph-function)
250 (kill-local-variable 'backward-delete-char-untabify-method))) 254 (kill-local-variable 'backward-delete-char-untabify-method)))
251 255
252 (provide 'refill) 256 (provide 'refill)
253 257
254 ;;; refill.el ends here 258 ;;; refill.el ends here