diff options
Diffstat (limited to 'lisp/subr.el')
| -rw-r--r-- | lisp/subr.el | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 6b0403890cf..13567d8753e 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1872,13 +1872,18 @@ Only affects hooks run in the current buffer." ;; PUBLIC: find if the current mode derives from another. +(defun provided-mode-derived-p (mode &rest modes) + "Non-nil if MODE is derived from one of MODES. +Uses the `derived-mode-parent' property of the symbol to trace backwards. +If you just want to check `major-mode', use `derived-mode-p'." + (while (and (not (memq mode modes)) + (setq mode (get mode 'derived-mode-parent)))) + mode) + (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)) + (apply #'provided-mode-derived-p major-mode modes)) ;;;; Minor modes. |
