(define-mode-clone): Renamed from mode-clone.
authorRichard M. Stallman <rms@gnu.org>
Fri, 4 Feb 1994 01:04:15 +0000 (01:04 +0000)
committerRichard M. Stallman <rms@gnu.org>
Fri, 4 Feb 1994 01:04:15 +0000 (01:04 +0000)
Swap args PARENT and CHILD.
Don't use clone-run-setup-function.
(clone-run-setup-function): Function deleted.

lisp/derived.el

index bd1aef1..3a89407 100644 (file)
@@ -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.
 
 ;; 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.
 ;; 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:
+The following simple command would clone LaTeX mode into
+LaTeX-Thesis mode:
 
-  (mode-clone LaTeX-mode LaTeX-thesis-mode \"LaTeX-Thesis\")
+  (define-mode-clone LaTeX-thesis-mode LaTeX-mode \"LaTeX-Thesis\")
 
-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).
+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 @@ been generated automatically, with a reference to the keymap."
         (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 @@ Right now, just set up a blank keymap and an empty syntax table."
 (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 @@ which more-or-less shadow
     (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."