1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

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'.
This commit is contained in:
Juri Linkov 2025-09-27 20:56:54 +03:00
parent 830272b306
commit 3cdc615218
3 changed files with 12 additions and 6 deletions

View file

@ -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

View file

@ -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.

View file

@ -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))