changeset 41975:2b1145fdbe6e

(derived-mode-p): Moved here from derived.el.
author Richard M. Stallman <rms@gnu.org>
date Wed, 12 Dec 2001 09:26:43 +0000
parents f59183ee53c5
children 1ae6951459ce
files lisp/subr.el
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/subr.el	Wed Dec 12 00:13:42 2001 +0000
+++ b/lisp/subr.el	Wed Dec 12 09:26:43 2001 +0000
@@ -1294,6 +1294,16 @@
      (let ((delay-mode-hooks t))
        ,@body)))
 
+;; PUBLIC: find if the current mode derives from another.
+
+(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))
+
 (defmacro with-syntax-table (table &rest body)
   "Evaluate BODY with syntax table of current buffer set to a copy of TABLE.
 The syntax table of the current buffer is saved, BODY is evaluated, and the