diff options
| -rw-r--r-- | lisp/textmodes/text-mode.el | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el index 9e89cb17e30..bb15f43cacc 100644 --- a/lisp/textmodes/text-mode.el +++ b/lisp/textmodes/text-mode.el | |||
| @@ -66,18 +66,13 @@ inherit all the commands defined in this map.") | |||
| 66 | (define-key text-mode-map "\eS" 'center-paragraph)) | 66 | (define-key text-mode-map "\eS" 'center-paragraph)) |
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | (defun text-mode () | 69 | (define-derived-mode text-mode nil "Text" |
| 70 | "Major mode for editing text written for humans to read. | 70 | "Major mode for editing text written for humans to read. |
| 71 | In this mode, paragraphs are delimited only by blank or white lines. | 71 | In this mode, paragraphs are delimited only by blank or white lines. |
| 72 | You can thus get the full benefit of adaptive filling | 72 | You can thus get the full benefit of adaptive filling |
| 73 | (see the variable `adaptive-fill-mode'). | 73 | (see the variable `adaptive-fill-mode'). |
| 74 | \\{text-mode-map} | 74 | \\{text-mode-map} |
| 75 | Turning on Text mode runs the normal hook `text-mode-hook'." | 75 | Turning on Text mode runs the normal hook `text-mode-hook'." |
| 76 | (interactive) | ||
| 77 | (kill-all-local-variables) | ||
| 78 | (use-local-map text-mode-map) | ||
| 79 | (setq local-abbrev-table text-mode-abbrev-table) | ||
| 80 | (set-syntax-table text-mode-syntax-table) | ||
| 81 | (make-local-variable 'paragraph-start) | 76 | (make-local-variable 'paragraph-start) |
| 82 | (setq paragraph-start (concat page-delimiter "\\|[ \t]*$")) | 77 | (setq paragraph-start (concat page-delimiter "\\|[ \t]*$")) |
| 83 | (if (eq ?^ (aref paragraph-start 0)) | 78 | (if (eq ?^ (aref paragraph-start 0)) |
| @@ -85,10 +80,7 @@ Turning on Text mode runs the normal hook `text-mode-hook'." | |||
| 85 | (make-local-variable 'paragraph-separate) | 80 | (make-local-variable 'paragraph-separate) |
| 86 | (setq paragraph-separate paragraph-start) | 81 | (setq paragraph-separate paragraph-start) |
| 87 | (make-local-variable 'indent-line-function) | 82 | (make-local-variable 'indent-line-function) |
| 88 | (setq indent-line-function 'indent-relative-maybe) | 83 | (setq indent-line-function 'indent-relative-maybe)) |
| 89 | (setq mode-name "Text") | ||
| 90 | (setq major-mode 'text-mode) | ||
| 91 | (run-hooks 'text-mode-hook)) | ||
| 92 | 84 | ||
| 93 | (defun paragraph-indent-text-mode () | 85 | (defun paragraph-indent-text-mode () |
| 94 | "Major mode for editing text, with leading spaces starting a paragraph. | 86 | "Major mode for editing text, with leading spaces starting a paragraph. |
| @@ -136,16 +128,14 @@ This is how `toggle-text-mode-auto-fill' knows which buffers to operate on." | |||
| 136 | This command affects all buffers that use modes related to Text mode, | 128 | This command affects all buffers that use modes related to Text mode, |
| 137 | both existing buffers and buffers that you subsequently create." | 129 | both existing buffers and buffers that you subsequently create." |
| 138 | (interactive) | 130 | (interactive) |
| 139 | (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook))) | 131 | (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook)))) |
| 140 | (buffers (buffer-list))) | ||
| 141 | (if enable-mode | 132 | (if enable-mode |
| 142 | (add-hook 'text-mode-hook 'turn-on-auto-fill) | 133 | (add-hook 'text-mode-hook 'turn-on-auto-fill) |
| 143 | (remove-hook 'text-mode-hook 'turn-on-auto-fill)) | 134 | (remove-hook 'text-mode-hook 'turn-on-auto-fill)) |
| 144 | (while buffers | 135 | (dolist (buffer (buffer-list)) |
| 145 | (with-current-buffer (car buffers) | 136 | (with-current-buffer buffer |
| 146 | (if text-mode-variant | 137 | (if (or (derived-mode-p 'text-mode) text-mode-variant) |
| 147 | (auto-fill-mode (if enable-mode 1 0)))) | 138 | (auto-fill-mode (if enable-mode 1 0))))) |
| 148 | (setq buffers (cdr buffers))) | ||
| 149 | (message "Auto Fill %s in Text modes" | 139 | (message "Auto Fill %s in Text modes" |
| 150 | (if enable-mode "enabled" "disabled")))) | 140 | (if enable-mode "enabled" "disabled")))) |
| 151 | 141 | ||