]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/derived.el
(make-char): Fix typo in docstring.
[gnu-emacs] / lisp / emacs-lisp / derived.el
index 8e1f79f95ee39a8386b8215d5785bedcffc8fb16..10482bd49c468d5617051099b461f0d1a428e786 100644 (file)
@@ -2,7 +2,7 @@
 ;; (formerly mode-clone.el)
 
 ;; Copyright (C) 1993, 1994, 1999, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: David Megginson (dmeggins@aix1.uottawa.ca)
 ;; Maintainer: FSF
@@ -194,13 +194,25 @@ See Info node `(elisp)Derived Modes' for more details."
                     parent child docstring syntax abbrev))
 
     `(progn
-       (defvar ,hook nil ,(format "Hook run when entering %s mode." name))
+       (unless (get  ',hook 'variable-documentation)
+        (put ',hook 'variable-documentation
+             ,(format "Hook run when entering %s mode.
+No problems result if this variable is not bound.
+`add-hook' automatically binds it.  (This is true for all hook variables.)"
+                      name)))
+       (unless (boundp ',map)
+        (put ',map 'definition-name ',child))
        (defvar ,map (make-sparse-keymap))
        ,(if declare-syntax
-           `(defvar ,syntax (make-syntax-table)))
+           `(progn
+              (unless (boundp ',syntax)
+                (put ',syntax 'definition-name ',child))
+              (defvar ,syntax (make-syntax-table))))
        ,(if declare-abbrev
-           `(defvar ,abbrev
-              (progn (define-abbrev-table ',abbrev nil) ,abbrev)))
+           `(progn
+              (put ',abbrev 'definition-name ',child)
+              (defvar ,abbrev
+                (progn (define-abbrev-table ',abbrev nil) ,abbrev))))
        (put ',child 'derived-mode-parent ',parent)
        ,(if group `(put ',child 'custom-mode-group ,group))