]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/derived.el
upstream
[gnu-emacs] / lisp / emacs-lisp / derived.el
index 1db98ac39c8ba67ccefcdf239f1db68518921e0b..119479b2c0a28c7e376a63f9c3bd22bc071bbc2d 100644 (file)
@@ -1,7 +1,7 @@
 ;;; derived.el --- allow inheritance of major modes
 ;; (formerly mode-clone.el)
 
-;; Copyright (C) 1993-1994, 1999, 2001-2011  Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 1999, 2001-2012  Free Software Foundation, Inc.
 
 ;; Author: David Megginson (dmeggins@aix1.uottawa.ca)
 ;; Maintainer: FSF
@@ -133,10 +133,10 @@ BODY can start with a bunch of keyword arguments.  The following keyword
        Declare the customization group that corresponds to this mode.
        The command `customize-mode' uses this.
 :syntax-table TABLE
-       Use TABLE instead of the default.
+       Use TABLE instead of the default (CHILD-syntax-table).
        A nil value means to simply use the same syntax-table as the parent.
 :abbrev-table TABLE
-       Use TABLE instead of the default.
+       Use TABLE instead of the default (CHILD-abbrev-table).
        A nil value means to simply use the same abbrev-table as the parent.
 
 Here is how you could define LaTeX-Thesis mode as a variant of LaTeX mode:
@@ -230,7 +230,7 @@ No problems result if this variable is not bound.
                                        ; Run the parent.
         (delay-mode-hooks
 
-         (,(or parent 'fundamental-mode))
+         (,(or parent 'kill-all-local-variables))
                                        ; Identify the child mode.
          (setq major-mode (quote ,child))
          (setq mode-name ,name)
@@ -253,8 +253,14 @@ No problems result if this variable is not bound.
                   `(let ((parent (char-table-parent ,syntax)))
                      (unless (and parent
                                   (not (eq parent (standard-syntax-table))))
-                       (set-char-table-parent ,syntax (syntax-table)))))))
-
+                       (set-char-table-parent ,syntax (syntax-table)))))
+                ,(when declare-abbrev
+                   `(unless (or (abbrev-table-get ,abbrev :parents)
+                                ;; This can happen if the major mode defines
+                                ;; the abbrev-table to be its parent's.
+                                (eq ,abbrev local-abbrev-table))
+                      (abbrev-table-put ,abbrev :parents
+                                        (list local-abbrev-table))))))
          (use-local-map ,map)
          ,(when syntax `(set-syntax-table ,syntax))
          ,(when abbrev `(setq local-abbrev-table ,abbrev))