From: Richard M. Stallman Date: Wed, 12 Dec 2001 09:26:43 +0000 (+0000) Subject: (derived-mode-p): Moved here from derived.el. X-Git-Tag: ttn-vms-21-2-B4~17772 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=31ca596b970d838877353b06df675c7a4fdeddb2;p=emacs.git (derived-mode-p): Moved here from derived.el. --- diff --git a/lisp/subr.el b/lisp/subr.el index 4232fd77e09..4029b7fa334 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1294,6 +1294,16 @@ Only affects hooks run in the current buffer." (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