Mercurial > hg > xemacs-beta
comparison lisp/derived.el @ 906:7f5ac0d2a71f
[xemacs-hg @ 2002-07-08 08:21:47 by youngs]
2002-06-26 John Paul Wallington <jpw@shootybangbang.com>
* derived.el (define-derived-mode): Put `derived-mode-parent'
property on child.
(derived-mode-p): New function; sync with GNU Emacs 21.
2002-06-26 Jerry James <james@xemacs.org>
* symbols.c (check_sane_subr): Let the symbol be bound if it is an
autoload cookie.
author | youngs |
---|---|
date | Mon, 08 Jul 2002 08:22:00 +0000 |
parents | 023b83f4e54b |
children | e2ddc2a2b794 |
comparison
equal
deleted
inserted
replaced
905:c15f25529e61 | 906:7f5ac0d2a71f |
---|---|
146 (setq docstring nil))) | 146 (setq docstring nil))) |
147 (setq docstring (or docstring (derived-mode-make-docstring parent child))) | 147 (setq docstring (or docstring (derived-mode-make-docstring parent child))) |
148 | 148 |
149 `(progn | 149 `(progn |
150 (derived-mode-init-mode-variables (quote ,child)) | 150 (derived-mode-init-mode-variables (quote ,child)) |
151 (put (quote ,child) 'derived-mode-parent (quote ,parent)) | |
151 (defun ,child () | 152 (defun ,child () |
152 ,docstring | 153 ,docstring |
153 (interactive) | 154 (interactive) |
154 ; Run the parent. | 155 ; Run the parent. |
155 (,parent) | 156 (,parent) |
185 Use the `derived-mode-parent' property of the symbol to trace backwards." | 186 Use the `derived-mode-parent' property of the symbol to trace backwards." |
186 (while (get mode 'derived-mode-parent) | 187 (while (get mode 'derived-mode-parent) |
187 (setq mode (get mode 'derived-mode-parent))) | 188 (setq mode (get mode 'derived-mode-parent))) |
188 mode) | 189 mode) |
189 | 190 |
191 ;; PUBLIC: find if the current mode derives from another. | |
192 ;; from GNU Emacs 21 subr.el | |
193 | |
194 (defun derived-mode-p (&rest modes) | |
195 "Non-nil if the current major mode is derived from one of MODES. | |
196 Uses the `derived-mode-parent' property of the symbol to trace backwards." | |
197 (let ((parent major-mode)) | |
198 (while (and (not (memq parent modes)) | |
199 (setq parent (get parent 'derived-mode-parent)))) | |
200 parent)) | |
201 | |
190 | 202 |
191 ;; Inline functions to construct various names from a mode name. | 203 ;; Inline functions to construct various names from a mode name. |
192 | 204 |
193 (defsubst derived-mode-setup-function-name (mode) | 205 (defsubst derived-mode-setup-function-name (mode) |
194 "Construct a setup-function name based on a mode name." | 206 "Construct a setup-function name based on a mode name." |