aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman1994-02-04 01:04:15 +0000
committerRichard M. Stallman1994-02-04 01:04:15 +0000
commitb72226e37e48efc1ad2c3af40d9c8fd7dd27ebbd (patch)
tree3f7ac0de6bfad795234bc2dd817cef51141eddbb /lisp
parent76078cf0dd9c70ba218b75071b4ff9610c42afb9 (diff)
downloademacs-b72226e37e48efc1ad2c3af40d9c8fd7dd27ebbd.tar.gz
emacs-b72226e37e48efc1ad2c3af40d9c8fd7dd27ebbd.zip
(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')
-rw-r--r--lisp/derived.el68
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 @@
1;;; mode-clone.el (alpha version) -- allow inheritance of major modes. 1;;; mode-clone.el (alpha version) -- allow inheritance of major modes.
2;;; $Id: mode-clone.el,v 1.5 1993/12/25 14:02:33 david Exp $
3 2
4;; Copyright (C) 1993 Free Software Foundation, Inc. 3;; Copyright (C) 1993 Free Software Foundation, Inc.
5 4
@@ -39,13 +38,13 @@
39;; it is most similar to, then list the (few) differences. 38;; it is most similar to, then list the (few) differences.
40;; 39;;
41;; In the mean time, this package offers most of the advantages of 40;; In the mean time, this package offers most of the advantages of
42;; full inheritance with the existing major modes. The function 41;; full inheritance with the existing major modes. The macro
43;; `mode-clone' allows the user to make a clone of an existing 42;; `define-mode-clone' allows the user to make a clone of an existing
44;; major mode, with its own keymap. The new mode will inherit the key 43;; major mode, with its own keymap. The new mode will inherit the key
45;; bindings of its parent, and will, in fact, run its parent first 44;; bindings of its parent, and will, in fact, run its parent first
46;; every time it is called. For example, the commands 45;; every time it is called. For example, the commands
47;; 46;;
48;; (mode-clone text-mode hypertext-mode "Hypertext" 47;; (define-mode-clone hypertext-mode text-mode "Hypertext"
49;; "Major mode for hypertext.\n\n\\{hypertext-mode-map}" 48;; "Major mode for hypertext.\n\n\\{hypertext-mode-map}"
50;; (setq case-fold-search nil)) 49;; (setq case-fold-search nil))
51;; 50;;
@@ -81,7 +80,7 @@
81;; sense. Second, it is possible to build even further, and clone the 80;; sense. Second, it is possible to build even further, and clone the
82;; clone. The commands 81;; clone. The commands
83;; 82;;
84;; (mode-clone hypertext-mode html-mode "HTML") 83;; (define-mode-clone html-mode hypertext-mode "HTML")
85;; [various key definitions] 84;; [various key definitions]
86;; 85;;
87;; will add a new major mode for HTML with very little fuss. 86;; will add a new major mode for HTML with very little fuss.
@@ -99,35 +98,32 @@
99;; PUBLIC: define a new major mode which inherits from an existing one. 98;; PUBLIC: define a new major mode which inherits from an existing one.
100 99
101;;;###autoload 100;;;###autoload
102(defmacro mode-clone (parent child name &optional docstring &rest body) 101(defmacro define-mode-clone (child parent name &optional docstring &rest body)
103 "Create a new mode which is similar to an old one. 102 "Create a new mode which is similar to an old one.
104 103
105The arguments to this command are as follow: 104The arguments to this command are as follow:
106 105
107parent: the name of the command for the parent mode (ie. text-mode) 106PARENT: the name of the command for the parent mode (ie. text-mode).
108child: the name of the command for the clone 107CHILD: the name of the command for the clone mode.
109name: a string which will appear in the status line (ie. \"Hypertext\") 108NAME: a string which will appear in the status line (ie. \"Hypertext\")
110docstring: an optional documentation string -- if you do not supply one, 109DOCSTRING: an optional documentation string--if you do not supply one,
111 the function will attempt to invent something useful. If this 110 the function will attempt to invent something useful.
112 argument is not a string, it will be added to body automatically. 111BODY: forms to execute just before running the
113body: a body of commands to execute just before running the
114 hooks for the new mode. 112 hooks for the new mode.
115 113
116The following simple command would clone LaTeX-mode into 114The following simple command would clone LaTeX mode into
117LaTeX-thesis-mode: 115LaTeX-Thesis mode:
118 116
119 (mode-clone LaTeX-mode LaTeX-thesis-mode \"LaTeX-Thesis\") 117 (define-mode-clone LaTeX-thesis-mode LaTeX-mode \"LaTeX-Thesis\")
120 118
121It would then be possible to assign commands to keystrokes in 119You could then make new key bindings for `LaTeX-thesis-mode-map'
122`LaTeX-thesis-mode-map' without changing the interface in the regular 120without changing regular LaTeX mode. In this example, BODY is empty,
123LaTeX-mode. The function (LaTeX-thesis-mode-setup), if it exists, 121and DOCSTRING is generated by default.
124will contain commands which will run whenever (LaTeX-thesis-mode) is
125run (just before 'LaTeX-thesis-mode-hooks).
126 122
127On a more complicated level, the following command would clone 123On a more complicated level, the following command would clone
128sgml-mode and change the variable `case-fold-search' to nil: 124sgml-mode and change the variable `case-fold-search' to nil:
129 125
130 (mode-clone sgml-mode article-mode \"Article\" 126 (define-mode-clone article-mode sgml-mode \"Article\"
131 \"Major mode for editing technical articles.\" 127 \"Major mode for editing technical articles.\"
132 (setq case-fold-search nil)) 128 (setq case-fold-search nil))
133 129
@@ -162,10 +158,10 @@ been generated automatically, with a reference to the keymap."
162 (clone-set-abbrev-table (quote (, child))) 158 (clone-set-abbrev-table (quote (, child)))
163 ; Splice in the body (if any). 159 ; Splice in the body (if any).
164 (,@ body) 160 (,@ body)
165 ; Run the setup function, if 161;;; ; Run the setup function, if
166 ; any -- this will soon be 162;;; ; any -- this will soon be
167 ; obsolete. 163;;; ; obsolete.
168 (clone-run-setup-function (quote (, child))) 164;;; (clone-run-setup-function (quote (, child)))
169 ; Run the hooks, if any. 165 ; Run the hooks, if any.
170 (clone-run-hooks (quote (, child))))))) 166 (clone-run-hooks (quote (, child)))))))
171 167
@@ -228,15 +224,15 @@ Right now, just set up a blank keymap and an empty syntax table."
228(defun clone-make-docstring (parent child) 224(defun clone-make-docstring (parent child)
229 "Construct a docstring for a new mode if none is provided." 225 "Construct a docstring for a new mode if none is provided."
230 226
231 (format "This major mode is a clone of (%s), created by (mode-clone). 227 (format "This major mode is a clone of `%s', created by `define-mode-clone'.
232It inherits all of the parent's attributes, but has its own keymap 228It inherits all of the parent's attributes, but has its own keymap,
233and syntax table: 229abbrev table and syntax table:
234 230
235 '%s-map' and '%s-syntax-table' 231 `%s-map' and `%s-syntax-table'
236 232
237which more-or-less shadow 233which more-or-less shadow
238 234
239 '%s-map' and '%s-syntax-table' 235 `%s-map' and `%s-syntax-table'
240 236
241\\{%s-map}" parent child child parent parent child)) 237\\{%s-map}" parent child child parent parent child))
242 238
@@ -271,12 +267,12 @@ which more-or-less shadow
271 (if table 267 (if table
272 (setq local-abbrev-table table)))) 268 (setq local-abbrev-table table))))
273 269
274(defun clone-run-setup-function (mode) 270;;;(defun clone-run-setup-function (mode)
275 "Run the setup function if it exists." 271;;; "Run the setup function if it exists."
276 272
277 (let ((fname (clone-setup-function-name mode))) 273;;; (let ((fname (clone-setup-function-name mode)))
278 (if (fboundp fname) 274;;; (if (fboundp fname)
279 (funcall fname)))) 275;;; (funcall fname))))
280 276
281(defun clone-run-hooks (mode) 277(defun clone-run-hooks (mode)
282 "Run the hooks if they exist." 278 "Run the hooks if they exist."