Function: provided-mode-derived-p

provided-mode-derived-p is a byte-compiled function defined in subr.el.gz.

Signature

(provided-mode-derived-p MODE &rest MODES)

Documentation

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.

This function has :after-until advice: TeX--compat-provided-mode-derived-p.

Probably introduced at or before Emacs version 27.1.

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
;; 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'."
  ;; If MODE is an alias, then look up the real mode function first.
  (when-let ((alias (symbol-function mode)))
    (when (symbolp alias)
      (setq mode alias)))
  (while
      (and
       (not (memq mode modes))
       (let* ((parent (get mode 'derived-mode-parent))
              (parentfn (symbol-function parent)))
         (setq mode (if (and parentfn (symbolp parentfn)) parentfn parent)))))
  mode)