* doc/lispref/modes.texi (Derived Modes): Document new derived-modes API.
* test/lisp/subr-tests.el (subt-tests--merge-ordered-lists): New test.
derived from any of the major modes given by the symbols @var{modes}.
@end defun
+The graph of major modes is accessed with the following lower-level
+functions:
+
+@defun derived-mode-set-parent mode parent
+This function declares that @var{mode} inherits from @code{parent}.
+This is the function that @code{define-derived-mode} calls after
+defining @var{mode} to register the fact that @var{mode} was defined
+by reusing @code{parent}.
+@end defun
+
+@defun derived-mode-add-parents mode extra-parents
+This function makes it possible to register additional parents beside
+the one that was used when defining @var{mode}. This can be used when
+the similarity between @var{mode} and the modes in @var{extra-parents}
+is such that it makes sense to treat it as a child of those
+modes for purposes like applying directory-local variables.
+@end defun
+
+@defun derived-mode-all-parents mode
+This function returns the list of all the modes in the ancestry of
+@var{mode}, ordered from the most specific to the least specific, and
+starting with @var{mode} itself.
+@end defun
+
+
@node Basic Major Modes
@subsection Basic Major Modes
\f
* Lisp Changes in Emacs 30.1
+** New function 'merge-ordered-lists'.
+Mostly used internally to do a kind of topological sort of
+inheritance hierarchies.
+
+** New API to control the graph of major modes.
+While 'define-derived-mode' still only support single inheritance,
+modes can declare additional parents (for tests like 'derived-mode-p')
+with `derived-mode-add-parents`.
+Accessing the 'derived-mode-parent' property directly is now
+deprecated in favor of the new functions 'derived-mode-set-parent'
+and 'derived-mode-all-parents'.
+
+++
** Drag-and-drop functions can now be called once for compound drops.
It is now possible for drag-and-drop handler functions to respond to
'(subr-tests--mode-A subr-tests--mode-B prog-mode
subr-tests--mode-C subr-tests--derived-mode-1))))))
+(ert-deftest subt-tests--merge-ordered-lists ()
+ (should (equal (merge-ordered-lists
+ '((B A) (C A) (D B) (E D C)))
+ '(E D B C A)))
+ (should (equal (merge-ordered-lists
+ '((E D C) (B A) (C A) (D B)))
+ '(E D C B A)))
+ (should-error (merge-ordered-lists
+ '((E C D) (B A) (A C) (D B))
+ (lambda (_) (error "cycle")))))
(ert-deftest number-sequence-test ()
(should (= (length