diff lisp/derived.el @ 5766:27a2ad893b22

(define-mode-clone): Renamed from mode-clone. Swap args PARENT and CHILD. Don't use clone-run-setup-function. (clone-run-setup-function): Function deleted.
author Richard M. Stallman <rms@gnu.org>
date Fri, 04 Feb 1994 01:04:15 +0000
parents 021bdb142040
children d81345ecac1a
line wrap: on
line diff
--- a/lisp/derived.el	Fri Feb 04 00:30:33 1994 +0000
+++ b/lisp/derived.el	Fri Feb 04 01:04:15 1994 +0000
@@ -1,5 +1,4 @@
 ;;; mode-clone.el (alpha version) -- allow inheritance of major modes.
-;;; $Id: mode-clone.el,v 1.5 1993/12/25 14:02:33 david Exp $
 
 ;; Copyright (C) 1993 Free Software Foundation, Inc.
 
@@ -39,13 +38,13 @@
 ;; it is most similar to, then list the (few) differences.
 ;;
 ;; In the mean time, this package offers most of the advantages of
-;; full inheritance with the existing major modes.  The function
-;; `mode-clone' allows the user to make a clone of an existing
+;; full inheritance with the existing major modes.  The macro
+;; `define-mode-clone' allows the user to make a clone of an existing
 ;; major mode, with its own keymap.  The new mode will inherit the key
 ;; bindings of its parent, and will, in fact, run its parent first
 ;; every time it is called.  For example, the commands
 ;;
-;;  (mode-clone text-mode hypertext-mode "Hypertext"
+;;  (define-mode-clone hypertext-mode text-mode "Hypertext"
 ;;    "Major mode for hypertext.\n\n\\{hypertext-mode-map}"
 ;;    (setq case-fold-search nil))
 ;;
@@ -81,7 +80,7 @@
 ;; sense.  Second, it is possible to build even further, and clone the
 ;; clone.  The commands
 ;;
-;;   (mode-clone hypertext-mode html-mode "HTML")
+;;   (define-mode-clone html-mode hypertext-mode "HTML")
 ;;   [various key definitions]
 ;; 
 ;; will add a new major mode for HTML with very little fuss.
@@ -99,35 +98,32 @@
 ;; PUBLIC: define a new major mode which inherits from an existing one.
 
 ;;;###autoload
-(defmacro mode-clone (parent child name &optional docstring &rest body)
+(defmacro define-mode-clone (child parent name &optional docstring &rest body)
   "Create a new mode which is similar to an old one.
 
 The arguments to this command are as follow:
 
-parent:    the name of the command for the parent mode (ie. text-mode)
-child:     the name of the command for the clone
-name:      a string which will appear in the status line (ie. \"Hypertext\")
-docstring: an optional documentation string -- if you do not supply one,
-           the function will attempt to invent something useful.  If this
-           argument is not a string, it will be added to body automatically.
-body:      a body of commands to execute just before running the
+PARENT:    the name of the command for the parent mode (ie. text-mode).
+CHILD:     the name of the command for the clone mode.
+NAME:      a string which will appear in the status line (ie. \"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.
 
-The following simple command would clone LaTeX-mode into
-LaTeX-thesis-mode:
-
-  (mode-clone LaTeX-mode LaTeX-thesis-mode \"LaTeX-Thesis\")
+The following simple command would clone LaTeX mode into
+LaTeX-Thesis mode:
 
-It would then be possible to assign commands to keystrokes in
-`LaTeX-thesis-mode-map' without changing the interface in the regular
-LaTeX-mode.  The function (LaTeX-thesis-mode-setup), if it exists,
-will contain commands which will run whenever (LaTeX-thesis-mode) is
-run (just before 'LaTeX-thesis-mode-hooks).
+  (define-mode-clone LaTeX-thesis-mode LaTeX-mode \"LaTeX-Thesis\")
+
+You could then make new key bindings for `LaTeX-thesis-mode-map'
+without changing regular LaTeX mode.  In this example, BODY is empty,
+and DOCSTRING is generated by default.
 
 On a more complicated level, the following command would clone
 sgml-mode and change the variable `case-fold-search' to nil:
 
-  (mode-clone sgml-mode article-mode \"Article\"
+  (define-mode-clone article-mode sgml-mode \"Article\"
     \"Major mode for editing technical articles.\"
     (setq case-fold-search nil))
 
@@ -162,10 +158,10 @@
 	 (clone-set-abbrev-table (quote (, child)))
 					; Splice in the body (if any).
 	 (,@ body)
-					; Run the setup function, if
-					; any -- this will soon be
-					; obsolete.
-	 (clone-run-setup-function (quote (, child)))
+;;;					; Run the setup function, if
+;;;					; any -- this will soon be
+;;;					; obsolete.
+;;;	 (clone-run-setup-function (quote (, child)))
 					; Run the hooks, if any.
 	 (clone-run-hooks (quote (, child)))))))
 
@@ -228,15 +224,15 @@
 (defun clone-make-docstring (parent child)
   "Construct a docstring for a new mode if none is provided."
 
-  (format "This major mode is a clone of (%s), created by (mode-clone).
-It inherits all of the parent's attributes, but has its own keymap
-and syntax table:
+  (format "This major mode is a clone of `%s', created by `define-mode-clone'.
+It inherits all of the parent's attributes, but has its own keymap,
+abbrev table and syntax table:
 
-  '%s-map' and '%s-syntax-table'
+  `%s-map' and `%s-syntax-table'
 
 which more-or-less shadow
 
-  '%s-map' and '%s-syntax-table'
+  `%s-map' and `%s-syntax-table'
 
 \\{%s-map}" parent child child parent parent child))
 
@@ -271,12 +267,12 @@
     (if table
 	(setq local-abbrev-table table))))
 
-(defun clone-run-setup-function (mode)
-  "Run the setup function if it exists."
+;;;(defun clone-run-setup-function (mode)
+;;;  "Run the setup function if it exists."
 
-  (let ((fname (clone-setup-function-name mode)))
-    (if (fboundp fname)
-	(funcall fname))))
+;;;  (let ((fname (clone-setup-function-name mode)))
+;;;    (if (fboundp fname)
+;;;	(funcall fname))))
 
 (defun clone-run-hooks (mode)
   "Run the hooks if they exist."