]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow provided-mode-derived-p to work on aliases
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 6 Feb 2021 11:03:43 +0000 (12:03 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 6 Feb 2021 11:03:47 +0000 (12:03 +0100)
* 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)

lisp/subr.el

index 6e52bd20df2c6461b3995d54ac98cf71f1d29f49..c1624aa9c02064af0cb639c0c4d840eb8c889368 100644 (file)
@@ -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))