X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/a9873dbbeb907016323fc434c8e85a2847afbc9a..5dd1c041c7fdb876b52bf33f41e8aeb119282cef:/lisp/emacs-lisp/derived.el diff --git a/lisp/emacs-lisp/derived.el b/lisp/emacs-lisp/derived.el index 006b6f2c58..10482bd49c 100644 --- a/lisp/emacs-lisp/derived.el +++ b/lisp/emacs-lisp/derived.el @@ -1,7 +1,8 @@ ;;; derived.el --- allow inheritance of major modes ;; (formerly mode-clone.el) -;; Copyright (C) 1993, 1994, 1999, 2003 Free Software Foundation, Inc. +;; Copyright (C) 1993, 1994, 1999, 2002, 2003, 2004, +;; 2005, 2006 Free Software Foundation, Inc. ;; Author: David Megginson (dmeggins@aix1.uottawa.ca) ;; Maintainer: FSF @@ -21,8 +22,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -96,7 +97,7 @@ ;;; PRIVATE: defsubst must be defined before they are first used (defsubst derived-mode-hook-name (mode) - "Construct the mode hook name based on mode name MODE." + "Construct a mode-hook name based on a MODE name." (intern (concat (symbol-name mode) "-hook"))) (defsubst derived-mode-map-name (mode) @@ -193,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)) @@ -382,18 +395,11 @@ Always merge its parent into it, since the merge is non-destructive." (derived-mode-merge-abbrev-tables old-table new-table) (setq local-abbrev-table new-table))) -;;;(defun derived-mode-run-setup-function (mode) -;;; "Run the setup function if it exists." - -;;; (let ((fname (derived-mode-setup-function-name mode))) -;;; (if (fboundp fname) -;;; (funcall fname)))) - (defun derived-mode-run-hooks (mode) - "Run the mode hook for MODE." - (let ((hooks-name (derived-mode-hook-name mode))) - (if (boundp hooks-name) - (run-hooks hooks-name)))) + "Run the mode hook for MODE." + (let ((hooks-name (derived-mode-hook-name mode))) + (if (boundp hooks-name) + (run-hooks hooks-name)))) ;; Functions to merge maps and tables.