changeset 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 c15f25529e61
children 6a68d74d1a04
files lisp/ChangeLog lisp/derived.el src/ChangeLog src/symbols.c
diffstat 4 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Jul 06 21:05:58 2002 +0000
+++ b/lisp/ChangeLog	Mon Jul 08 08:22:00 2002 +0000
@@ -1,3 +1,9 @@
+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-16  Andy Piper  <andy@xemacs.org>
 
 	* menubar-items.el (default-menubar): enable windows printing on
--- a/lisp/derived.el	Sat Jul 06 21:05:58 2002 +0000
+++ b/lisp/derived.el	Mon Jul 08 08:22:00 2002 +0000
@@ -148,6 +148,7 @@
 
   `(progn 
        (derived-mode-init-mode-variables (quote ,child))
+       (put (quote ,child) 'derived-mode-parent (quote ,parent))
        (defun ,child ()
 	 ,docstring
 	 (interactive)
@@ -187,6 +188,17 @@
     (setq mode (get mode 'derived-mode-parent)))
   mode)
 
+;; PUBLIC: find if the current mode derives from another.
+;; from GNU Emacs 21 subr.el
+
+(defun derived-mode-p (&rest modes)
+  "Non-nil if the current major mode is derived from one of MODES.
+Uses the `derived-mode-parent' property of the symbol to trace backwards."
+  (let ((parent major-mode))
+    (while (and (not (memq parent modes))
+		(setq parent (get parent 'derived-mode-parent))))
+    parent))
+
 
 ;; Inline functions to construct various names from a mode name.
 
--- a/src/ChangeLog	Sat Jul 06 21:05:58 2002 +0000
+++ b/src/ChangeLog	Mon Jul 08 08:22:00 2002 +0000
@@ -1,3 +1,8 @@
+2002-06-26  Jerry James  <james@xemacs.org>
+
+	* symbols.c (check_sane_subr): Let the symbol be bound if it is an
+	autoload cookie.
+
 2002-06-24  Andy Piper  <andy@xemacs.org>
 
 	* toolbar-x.c (console_type_create_toolbar_x): declare
--- a/src/symbols.c	Sat Jul 06 21:05:58 2002 +0000
+++ b/src/symbols.c	Mon Jul 08 08:22:00 2002 +0000
@@ -3362,6 +3362,8 @@
 static void
 check_sane_subr (Lisp_Subr *subr, Lisp_Object sym)
 {
+  Lisp_Object f;
+
   assert (subr->min_args >= 0);
   assert (subr->min_args <= SUBR_MAX_ARGS);
 
@@ -3373,7 +3375,8 @@
       assert (subr->min_args <= subr->max_args);
     }
 
-  assert (UNBOUNDP (XSYMBOL (sym)->function));
+  f = XSYMBOL (sym)->function;
+  assert (UNBOUNDP (f) || (CONSP (f) && EQ (XCAR (f), Qautoload)));
 }
 #else
 #define check_sane_subr(subr, sym) /* nothing */