diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2023-10-27 20:18:54 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2023-10-27 20:18:54 -0400 |
commit | 81510f2fff5e61c6fca359e01870139f1302e1ed (patch) | |
tree | c9722240ff1ddbeda5a133d7eb932bd5a4c49352 /lisp/subr.el | |
parent | 9acd8c8e530dda326ae5bf852c2437fdcde4e8cc (diff) | |
download | emacs-81510f2fff5e61c6fca359e01870139f1302e1ed.tar.gz |
(provided-mode-derived-p): Fix alias case
The new handling of aliases in `provided-mode-derived-p`
introduced in Emacs-28.1 caused a regression where
(provided-mode-derived-p MODE MODE) returns nil if MODE is an alias.
Rework the loop so we consider an alias as a kind of parent.
* lisp/subr.el (provided-mode-derived-p): Step over aliases separately.
* test/lisp/subr-tests.el (subr-tests--derived-mode-1)
(subr-tests--derived-mode-2): Move out of `provided-mode-derived-p`
and give them properly namespaced names.
(provided-mode-derived-p): Add more tests for aliases.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 12e33380260..d4173b4daba 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2682,17 +2682,15 @@ The variable list SPEC is the same as in `if-let*'." "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. (declare (side-effect-free t)) - (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))))) + (let* ((parent (get mode 'derived-mode-parent))) + (setq mode (or parent + ;; If MODE is an alias, then follow the alias. + (let ((alias (symbol-function mode))) + (and (symbolp alias) alias))))))) mode) (defun derived-mode-p (&rest modes) |