changeset 40360:04be247dd745

(text-mode): Use define-derived-mode. (toggle-text-mode-auto-fill): Use derived-mode-p.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 27 Oct 2001 07:42:11 +0000
parents a27a469ab31a
children 8c6df631e62d
files lisp/textmodes/text-mode.el
diffstat 1 files changed, 7 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/text-mode.el	Sat Oct 27 05:21:32 2001 +0000
+++ b/lisp/textmodes/text-mode.el	Sat Oct 27 07:42:11 2001 +0000
@@ -66,18 +66,13 @@
   (define-key text-mode-map "\eS" 'center-paragraph))
 
 
-(defun text-mode ()
+(define-derived-mode text-mode nil "Text"
   "Major mode for editing text written for humans to read.
 In this mode, paragraphs are delimited only by blank or white lines.
 You can thus get the full benefit of adaptive filling
  (see the variable `adaptive-fill-mode').
 \\{text-mode-map}
 Turning on Text mode runs the normal hook `text-mode-hook'."
-  (interactive)
-  (kill-all-local-variables)
-  (use-local-map text-mode-map)
-  (setq local-abbrev-table text-mode-abbrev-table)
-  (set-syntax-table text-mode-syntax-table)
   (make-local-variable 'paragraph-start)
   (setq paragraph-start (concat page-delimiter "\\|[ \t]*$"))
   (if (eq ?^ (aref paragraph-start 0))
@@ -85,10 +80,7 @@
   (make-local-variable 'paragraph-separate)
   (setq paragraph-separate paragraph-start)
   (make-local-variable 'indent-line-function)
-  (setq indent-line-function 'indent-relative-maybe)
-  (setq mode-name "Text")
-  (setq major-mode 'text-mode)
-  (run-hooks 'text-mode-hook))
+  (setq indent-line-function 'indent-relative-maybe))
 
 (defun paragraph-indent-text-mode ()
   "Major mode for editing text, with leading spaces starting a paragraph.
@@ -136,16 +128,14 @@
 This command affects all buffers that use modes related to Text mode,
 both existing buffers and buffers that you subsequently create."
   (interactive)
-  (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook)))
-	(buffers (buffer-list)))
+  (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook))))
     (if enable-mode
 	(add-hook 'text-mode-hook 'turn-on-auto-fill)
       (remove-hook 'text-mode-hook 'turn-on-auto-fill))
-    (while buffers
-      (with-current-buffer (car buffers)
-	(if text-mode-variant
-	    (auto-fill-mode (if enable-mode 1 0))))
-      (setq buffers (cdr buffers)))
+    (dolist (buffer (buffer-list))
+      (with-current-buffer buffer
+	(if (or (derived-mode-p 'text-mode) text-mode-variant)
+	    (auto-fill-mode (if enable-mode 1 0)))))
     (message "Auto Fill %s in Text modes"
 	     (if enable-mode "enabled" "disabled"))))