diff options
| author | Stefan Monnier | 2005-01-23 22:01:59 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-01-23 22:01:59 +0000 |
| commit | 04138be8a5ec7fe737916e171c7e3fec7d23c0e4 (patch) | |
| tree | 543575108996506154d38418afaacfff6afe6524 | |
| parent | f2fc1724a8569223120333218b2094a7f1114863 (diff) | |
| download | emacs-04138be8a5ec7fe737916e171c7e3fec7d23c0e4.tar.gz emacs-04138be8a5ec7fe737916e171c7e3fec7d23c0e4.zip | |
(refill-post-command-function):
Add `indent-new-comment-line' and `reindent-then-newline-and-indent'
to the list of functions that we should be careful not to undo.
(refill-late-fill-paragraph-function): Remove.
(refill-saved-state): New var.
(refill-mode): Use it to save fill-paragraph-function.
Save also the value of auto-fill-function.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/textmodes/refill.el | 84 |
2 files changed, 50 insertions, 42 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 987ac9d0bdc..53f6d66471b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -12,6 +12,14 @@ | |||
| 12 | 12 | ||
| 13 | 2005-01-23 Stefan Monnier <monnier@iro.umontreal.ca> | 13 | 2005-01-23 Stefan Monnier <monnier@iro.umontreal.ca> |
| 14 | 14 | ||
| 15 | * textmodes/refill.el (refill-post-command-function): | ||
| 16 | Add `indent-new-comment-line' and `reindent-then-newline-and-indent' | ||
| 17 | to the list of functions that we should be careful not to undo. | ||
| 18 | (refill-late-fill-paragraph-function): Remove. | ||
| 19 | (refill-saved-state): New var. | ||
| 20 | (refill-mode): Use it to save fill-paragraph-function. | ||
| 21 | Save also the value of auto-fill-function. | ||
| 22 | |||
| 15 | * term/w32-win.el: Simplify code. | 23 | * term/w32-win.el: Simplify code. |
| 16 | 24 | ||
| 17 | 2005-01-23 Kim F. Storm <storm@cua.dk> | 25 | 2005-01-23 Kim F. Storm <storm@cua.dk> |
diff --git a/lisp/textmodes/refill.el b/lisp/textmodes/refill.el index 60b64e9a9f2..9979f4a3e27 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, 2003 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2000, 2003, 2005 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Dave Love <fx@gnu.org> | 5 | ;; Author: Dave Love <fx@gnu.org> |
| 6 | ;; Maintainer: Miles Bader <miles@gnu.org> | 6 | ;; Maintainer: Miles Bader <miles@gnu.org> |
| @@ -85,6 +85,8 @@ | |||
| 85 | 85 | ||
| 86 | ;;; Code: | 86 | ;;; Code: |
| 87 | 87 | ||
| 88 | (eval-when-compile (require 'cl)) | ||
| 89 | |||
| 88 | (defgroup refill nil | 90 | (defgroup refill nil |
| 89 | "Refilling paragraphs on changes." | 91 | "Refilling paragraphs on changes." |
| 90 | :group 'fill) | 92 | :group 'fill) |
| @@ -169,40 +171,36 @@ complex processing.") | |||
| 169 | "Post-command function to do refilling (conditionally)." | 171 | "Post-command function to do refilling (conditionally)." |
| 170 | (when refill-doit ; there was a change | 172 | (when refill-doit ; there was a change |
| 171 | ;; There's probably scope for more special cases here... | 173 | ;; There's probably scope for more special cases here... |
| 172 | (if (eq this-command 'self-insert-command) | 174 | (case this-command |
| 173 | ;; Treat self-insertion commands specially, since they don't | 175 | (self-insert-command |
| 174 | ;; always reset `refill-doit' -- for self-insertion commands that | 176 | ;; Treat self-insertion commands specially, since they don't |
| 175 | ;; *don't* cause a refill, we want to leave it turned on so that | 177 | ;; always reset `refill-doit' -- for self-insertion commands that |
| 176 | ;; any subsequent non-modification command will cause a refill. | 178 | ;; *don't* cause a refill, we want to leave it turned on so that |
| 177 | (when (aref auto-fill-chars (char-before)) | 179 | ;; any subsequent non-modification command will cause a refill. |
| 178 | ;; Respond to the same characters as auto-fill (other than | 180 | (when (aref auto-fill-chars (char-before)) |
| 179 | ;; newline, covered below). | 181 | ;; Respond to the same characters as auto-fill (other than |
| 180 | (refill-fill-paragraph-at refill-doit) | 182 | ;; newline, covered below). |
| 181 | (setq refill-doit nil)) | 183 | (refill-fill-paragraph-at refill-doit) |
| 182 | (cond | 184 | (setq refill-doit nil))) |
| 183 | ((or (eq this-command 'quoted-insert) | 185 | ((quoted-insert fill-paragraph fill-region) nil) |
| 184 | (eq this-command 'fill-paragraph) | 186 | ((newline newline-and-indent open-line indent-new-comment-line |
| 185 | (eq this-command 'fill-region)) | 187 | reindent-then-newline-and-indent) |
| 186 | nil) | 188 | ;; Don't zap what was just inserted. |
| 187 | ((or (eq this-command 'newline) | 189 | (save-excursion |
| 188 | (eq this-command 'newline-and-indent) | 190 | (beginning-of-line) ; for newline-and-indent |
| 189 | (eq this-command 'open-line)) | 191 | (skip-chars-backward "\n") |
| 190 | ;; Don't zap what was just inserted. | 192 | (save-restriction |
| 191 | (save-excursion | 193 | (narrow-to-region (point-min) (point)) |
| 192 | (beginning-of-line) ; for newline-and-indent | 194 | (refill-fill-paragraph-at refill-doit))) |
| 193 | (skip-chars-backward "\n") | 195 | (widen) |
| 194 | (save-restriction | 196 | (save-excursion |
| 195 | (narrow-to-region (point-min) (point)) | 197 | (skip-chars-forward "\n") |
| 196 | (refill-fill-paragraph-at refill-doit))) | 198 | (save-restriction |
| 197 | (widen) | 199 | (narrow-to-region (line-beginning-position) (point-max)) |
| 198 | (save-excursion | 200 | (refill-fill-paragraph-at refill-doit)))) |
| 199 | (skip-chars-forward "\n") | 201 | (t |
| 200 | (save-restriction | 202 | (refill-fill-paragraph-at refill-doit))) |
| 201 | (narrow-to-region (line-beginning-position) (point-max)) | 203 | (setq refill-doit nil))) |
| 202 | (refill-fill-paragraph-at refill-doit)))) | ||
| 203 | (t | ||
| 204 | (refill-fill-paragraph-at refill-doit))) | ||
| 205 | (setq refill-doit nil)))) | ||
| 206 | 204 | ||
| 207 | (defun refill-pre-command-function () | 205 | (defun refill-pre-command-function () |
| 208 | "Pre-command function to do refilling (conditionally)." | 206 | "Pre-command function to do refilling (conditionally)." |
| @@ -213,7 +211,7 @@ complex processing.") | |||
| 213 | (refill-fill-paragraph-at refill-doit) | 211 | (refill-fill-paragraph-at refill-doit) |
| 214 | (setq refill-doit nil))) | 212 | (setq refill-doit nil))) |
| 215 | 213 | ||
| 216 | (defvar refill-late-fill-paragraph-function nil) | 214 | (defvar refill-saved-state nil) |
| 217 | 215 | ||
| 218 | ;;;###autoload | 216 | ;;;###autoload |
| 219 | (define-minor-mode refill-mode | 217 | (define-minor-mode refill-mode |
| @@ -228,16 +226,18 @@ refilling if they would cause auto-filling." | |||
| 228 | (when refill-ignorable-overlay | 226 | (when refill-ignorable-overlay |
| 229 | (delete-overlay refill-ignorable-overlay) | 227 | (delete-overlay refill-ignorable-overlay) |
| 230 | (kill-local-variable 'refill-ignorable-overlay)) | 228 | (kill-local-variable 'refill-ignorable-overlay)) |
| 231 | (when (local-variable-p 'refill-late-fill-paragraph-function) | 229 | (when (local-variable-p 'refill-saved-state) |
| 232 | (setq fill-paragraph-function refill-late-fill-paragraph-function) | 230 | (dolist (x refill-saved-state) |
| 233 | (kill-local-variable 'refill-late-fill-paragraph-function)) | 231 | (set (make-local-variable (car x)) (cdr x))) |
| 232 | (kill-local-variable 'refill-saved-state)) | ||
| 234 | (if refill-mode | 233 | (if refill-mode |
| 235 | (progn | 234 | (progn |
| 236 | (add-hook 'after-change-functions 'refill-after-change-function nil t) | 235 | (add-hook 'after-change-functions 'refill-after-change-function nil t) |
| 237 | (add-hook 'post-command-hook 'refill-post-command-function nil t) | 236 | (add-hook 'post-command-hook 'refill-post-command-function nil t) |
| 238 | (add-hook 'pre-command-hook 'refill-pre-command-function nil t) | 237 | (add-hook 'pre-command-hook 'refill-pre-command-function nil t) |
| 239 | (set (make-local-variable 'refill-late-fill-paragraph-function) | 238 | (set (make-local-variable 'refill-saved-state) |
| 240 | fill-paragraph-function) | 239 | (mapcar (lambda (s) (cons s (symbol-value s))) |
| 240 | '(fill-paragraph-function auto-fill-function))) | ||
| 241 | ;; This provides the test for recursive paragraph filling. | 241 | ;; This provides the test for recursive paragraph filling. |
| 242 | (set (make-local-variable 'fill-paragraph-function) | 242 | (set (make-local-variable 'fill-paragraph-function) |
| 243 | 'refill-fill-paragraph) | 243 | 'refill-fill-paragraph) |
| @@ -257,5 +257,5 @@ refilling if they would cause auto-filling." | |||
| 257 | 257 | ||
| 258 | (provide 'refill) | 258 | (provide 'refill) |
| 259 | 259 | ||
| 260 | ;;; arch-tag: 2c4ce9e8-1daa-4a3b-b6f8-fd6ac5bf6138 | 260 | ;; arch-tag: 2c4ce9e8-1daa-4a3b-b6f8-fd6ac5bf6138 |
| 261 | ;;; refill.el ends here | 261 | ;;; refill.el ends here |