]> code.delx.au - gnu-emacs/blobdiff - lisp/derived.el
(report_file_error): String pointer args now point to
[gnu-emacs] / lisp / derived.el
index 25b65bb1b1a720c0d8b5552ff1fd799e41a0446b..994509855e42ffec883c87e21ea082a879ea8646 100644 (file)
@@ -124,7 +124,7 @@ NAME:      a string which will appear in the status line (e.g. \"Hypertext\")
 DOCSTRING: an optional documentation string--if you do not supply one,
            the function will attempt to invent something useful.
 BODY:      forms to execute just before running the
-           hooks for the new mode.
+           hooks for the new mode.  Do not use `interactive' here.
 
 Here is how you could define LaTeX-Thesis mode as a variant of LaTeX mode:
 
@@ -161,8 +161,8 @@ been generated automatically, with a reference to the keymap."
     `(progn
        (defvar ,map (make-sparse-keymap))
        (defvar ,syntax (make-syntax-table))
-       (defvar ,abbrev)
-       (define-abbrev-table ',abbrev nil)
+       (defvar ,abbrev
+        (progn (define-abbrev-table ',abbrev nil) ,abbrev))
        (put ',child 'derived-mode-parent ',parent)
 
        (defun ,child ()
@@ -178,8 +178,9 @@ been generated automatically, with a reference to the keymap."
                                        ; Identify special modes.
          ,(when parent
             `(progn
-               (if (get (quote ,parent) 'special)
-                   (put (quote ,child) 'special t))
+               (if (get (quote ,parent) 'mode-class)
+                   (put (quote ,child) 'mode-class
+                        (get (quote ,parent) 'mode-class)))
                                        ; Set up maps and tables.
                (unless (keymap-parent ,map)
                  (set-keymap-parent ,map (current-local-map)))
@@ -203,28 +204,18 @@ been generated automatically, with a reference to the keymap."
                                        ; Run the hooks, if any.
         (run-mode-hooks ',hook)))))
 
-;; PUBLIC: find if the current mode derives from another.
-
-;;; ;;;###autoload
-(defun derived-mode-p (&rest modes)
-  "Non-nil if the current major mode is derived from one of MODES.
-Uses the `derived-mode-parent' property of the symbol to trace backwards."
-  (let ((parent major-mode))
-    (while (and (not (memq parent modes))
-               (setq parent (get parent 'derived-mode-parent))))
-    parent))
-
 ;; PUBLIC: find the ultimate class of a derived mode.
 
 (defun derived-mode-class (mode)
   "Find the class of a major MODE.
 A mode's class is the first ancestor which is NOT a derived mode.
 Use the `derived-mode-parent' property of the symbol to trace backwards.
-Since major-modes might derive from each other and from `fundamental-mode',
-this function is not very useful.  Use `derived-mode-p' instead."
+Since major-modes might all derive from `fundamental-mode', this function
+is not very useful."
   (while (get mode 'derived-mode-parent)
     (setq mode (get mode 'derived-mode-parent)))
   mode)
+(make-obsolete 'derived-mode-class 'derived-mode-p "21.4")
 
 \f
 ;;; PRIVATE