diff options
author | Richard M. Stallman <rms@gnu.org> | 1994-02-04 01:04:15 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1994-02-04 01:04:15 +0000 |
commit | 3148d1af4a133bd8cc53dcfc4ef2e4ed2c958d11 (patch) | |
tree | 0472850fe4d066e280d24939cfd378b00c79d758 /lisp/derived.el | |
parent | 0d9a46ce39f9d1c68d734d07febf017b30c83a94 (diff) | |
download | emacs-3148d1af4a133bd8cc53dcfc4ef2e4ed2c958d11.tar.gz |
(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.
Diffstat (limited to 'lisp/derived.el')
-rw-r--r-- | lisp/derived.el | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/lisp/derived.el b/lisp/derived.el index bd1aef1f841..3a89407749f 100644 --- a/lisp/derived.el +++ b/lisp/derived.el @@ -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: +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." |