summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-02-06 12:03:43 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-02-06 12:03:47 +0100
commit2476abc1f24f1b2385648cfb08cd9f178422497d (patch)
treef8387a7ce2df6e3b38e05e9e6484a4d0bf0db419
parent23a7da9148c84dbcc228dda37c9bcebfc2a004d2 (diff)
downloademacs-2476abc1f24f1b2385648cfb08cd9f178422497d.tar.gz
Allow provided-mode-derived-p to work on aliases
* lisp/subr.el (provided-mode-derived-p): Allow this to work on modes that are aliases of other modes (bug#46331). For instance: (provided-mode-derived-p 'javascript-mode 'prog-mode)
-rw-r--r--lisp/subr.el4
1 files changed, 4 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 6e52bd20df2..c1624aa9c02 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2231,6 +2231,10 @@ Affects only hooks run in the current buffer."
"Non-nil if MODE is derived from one of MODES or their aliases.
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))