From 3cdc615218458729b51a715bedc899e3df5bfa64 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sat, 27 Sep 2025 20:56:54 +0300 Subject: [PATCH] Improve documentation and customization of 'derived-mode' in buffer predicate * doc/lispref/buffers.texi (Buffer List): * lisp/subr.el (buffer-match-p): Document that 'derived-mode' can be a list (bug#79481). * lisp/wid-edit.el (buffer-predicate): Support a list for 'derived-mode'. --- doc/lispref/buffers.texi | 11 +++++++---- lisp/subr.el | 3 ++- lisp/wid-edit.el | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi index 01aa620b828..e759df5746c 100644 --- a/doc/lispref/buffers.texi +++ b/doc/lispref/buffers.texi @@ -991,10 +991,13 @@ Satisfied if @emph{any} condition in @var{conds} satisfies Satisfied if @emph{all} the conditions in @var{conds} satisfy @code{buffer-match-p}, with the same buffer and @code{args}. @item derived-mode -Satisfied if the buffer's major mode derives from @var{expr}. Note -that this condition might fail to report a match if -@code{buffer-match-p} is invoked before the major mode of the buffer -has been established. +Satisfied if the buffer's major mode derives from @var{expr}. +The value of @var{expr} can be either a single mode symbol +or a list of mode symbols as accepted by the function +@code{provided-mode-derived-p} (@pxref{Derived Modes}). +Note that this condition might fail to report a match if +@code{buffer-match-p} is invoked before the major mode of +the buffer has been established. @item major-mode Satisfied if the buffer's major mode is equal to @var{expr}. Prefer using @code{derived-mode} instead, when both can work. Note that this diff --git a/lisp/subr.el b/lisp/subr.el index da208d7063f..08c22737539 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -7651,7 +7651,8 @@ CONDITION is either: - a cons-cell, where the car describes how to interpret the cdr. The car can be one of the following: * `derived-mode': the buffer matches if the buffer's major mode - is derived from the major mode in the cons-cell's cdr. + is derived from the major mode in the cons-cell's cdr, or from any + major mode in the list as accepted by `provided-mode-derived-p'. * `major-mode': the buffer matches if the buffer's major mode is eq to the cons-cell's cdr. Prefer using `derived-mode' instead when both can work. diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index ee6679f9e63..da07231a4da 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -4395,7 +4395,9 @@ is inline." (function :tag "Predicate function") (cons :tag "Derived mode" (const derived-mode) - (symbol derived-mode)) + (choice + (symbol :tag "Single mode" derived-mode) + (repeat :tag "List of modes" (symbol derived-mode)))) (cons :tag "Major mode" (const major-mode) (symbol major-mode))