aboutsummaryrefslogtreecommitdiff
path: root/compat-26.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-01-21 17:40:23 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2023-01-21 17:40:23 +0100
commit9b984aeb088901fc8b238a5e52ae343ea1dac527 (patch)
tree3d1d26be0b1bda733f5f601cdbe72484a905e4fb /compat-26.el
parenta18351d539ac85ae31cd71520afff650ee5856b9 (diff)
Drop unneeded definitions
Diffstat (limited to 'compat-26.el')
-rw-r--r--compat-26.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/compat-26.el b/compat-26.el
index bdfb6e9..ad080f5 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -83,6 +83,22 @@ see `region-noncontiguous-p' and `extract-rectangle-bounds'."
;;;; Defined in subr.el
+(compat-defun provided-mode-derived-p (mode &rest modes) ;; <compat-tests:provided-derived-mode-p>
+ "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.
+ (let ((alias (symbol-function mode)))
+ (when (and alias (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)
+
(compat-defun alist-get (key alist &optional default remove testfn) ;; <compat-tests:alist-get>
"Handle optional argument TESTFN."
:explicit t