- (kill-all-local-variables)
- (use-local-map text-mode-map)
- (setq mode-name "Text")
- (setq major-mode 'text-mode)
- (setq local-abbrev-table text-mode-abbrev-table)
- (set-syntax-table text-mode-syntax-table)
- (run-hooks 'text-mode-hook))
-
-(defvar indented-text-mode-map ()
- "Keymap for Indented Text mode.
-All the commands defined in Text mode are inherited unless overridden.")
-
-(if indented-text-mode-map
- ()
- ;; Make different definition for TAB before the one in text-mode-map, but
- ;; share the rest.
- (let ((newmap (make-sparse-keymap)))
- (define-key newmap "\t" 'indent-relative)
- (setq indented-text-mode-map (nconc newmap text-mode-map))))
-
-(defun indented-text-mode ()
- "Major mode for editing text with indented paragraphs.
-In this mode, paragraphs are delimited only by blank lines.
-You can thus get the benefit of adaptive filling
- (see the variable `adaptive-fill-mode').
-\\{indented-text-mode-map}
-Turning on `indented-text-mode' calls the value of the variable
-`text-mode-hook', if that value is non-nil."
+ (set (make-local-variable 'paragraph-start)
+ (concat "[ \t\n\f]\\|" paragraph-start))
+ (set (make-local-variable 'indent-line-function) 'indent-to-left-margin)
+ (run-hooks 'paragraph-indent-text-mode-hook))
+
+(defalias 'indented-text-mode 'text-mode)
+
+;; This can be made a no-op once all modes that use text-mode-hook
+;; are "derived" from text-mode.
+(defun text-mode-hook-identify ()
+ "Mark that this mode has run `text-mode-hook'.
+This is how `toggle-text-mode-auto-fill' knows which buffers to operate on."
+ (set (make-local-variable 'text-mode-variant) t))
+
+(add-hook 'text-mode-hook 'text-mode-hook-identify)
+
+(defun toggle-text-mode-auto-fill ()
+ "Toggle whether to use Auto Fill in Text mode and related modes.
+This command affects all buffers that use modes related to Text mode,
+both existing buffers and buffers that you subsequently create."