Subject: bug#54296: Add buffer-matching functionality

From: Eli Zaretskii <[email-masked]>
Date: Thu, 10 Mar 2022 13:53:54 +0200

> From: Philip Kaludercic <[email-masked]>
> Date: Thu, 10 Mar 2022 10:05:04 +0000
> Cc: [email-masked]
> 
> +(defun buffer-match (condition buffer-or-name &optional arg)
> +  "Return non-nil if BUFFER-OR-NAME matches CONDITION.

This is a predicate function, so its name should be buffer-matches-p
or maybe buffer-matches-condition-p.

> +CONDITION is is either:
             ^^^^^
Typo.

> +- a regular expression, to match a buffer name,
> +- a predicate function that takes a buffer object and ARG as
> +  arguments and returns non-nil if the buffer matches,
              ^
Comma missing there.

> +- a cons-cell, where the car describes how to interpret the cdr.
> +  The car can be one of the following:
> +  * `major-mode': the buffer matches if the buffer's major
> +    mode is eq to the cons-cell's cdr
> +  * `derived-mode': the buffer matches if the buffer's major
> +    mode is derived from the major mode denoted by the cons-cell's
> +    cdr

Do we really need both major-mode and derived-mode?

> +  * `not': the cdr is interpreted as a negation of a condition.
> +  * `and': the cdr is a list of recursive condition, that all have
> +    to be met.                            ^^^^^^^^^

Typo: should be "conditions".

> +  * `or': the cdr is a list of recursive condition, of which at
> +    least one has to be met."            ^^^^^^^^^

Likewise.

Thanks.