Fix accidental backward-incompatible change (bug#62417)

This code used to work, but with the change of 59ecf25fc8 it stopped
working:

   (defun foop (buffer-name _alist) (string-match "foop" buffer-name))
   (add-to-list 'display-buffer-alist '(foop . display-buffer-other-frame))

This change makes it work again, restoring compatibility.

* lisp/subr.el (buffer-match-p): Fix and adjust docstring.
* lisp/window.el (display-buffer-alist): Adjust docstring.
(display-buffer-assq-regexp): Make good on promise of display-buffer-alist.
This commit is contained in:
João Távora 2023-03-27 12:25:16 +01:00
parent cbef1422fe
commit edc460e3b6
2 changed files with 13 additions and 9 deletions

View file

@ -7069,7 +7069,7 @@ CONDITION is either:
- the symbol t, to always match, - the symbol t, to always match,
- the symbol nil, which never matches, - the symbol nil, which never matches,
- a regular expression, to match a buffer name, - a regular expression, to match a buffer name,
- a predicate function that takes a buffer object and ARG as - a predicate function that takes BUFFER-OR-NAME and ARG as
arguments, and returns non-nil if the buffer matches, arguments, and returns non-nil if the buffer matches,
- a cons-cell, where the car describes how to interpret the cdr. - a cons-cell, where the car describes how to interpret the cdr.
The car can be one of the following: The car can be one of the following:
@ -7095,8 +7095,8 @@ CONDITION is either:
(string-match-p condition (buffer-name buffer))) (string-match-p condition (buffer-name buffer)))
((pred functionp) ((pred functionp)
(if (eq 1 (cdr (func-arity condition))) (if (eq 1 (cdr (func-arity condition)))
(funcall condition buffer) (funcall condition buffer-or-name)
(funcall condition buffer arg))) (funcall condition buffer-or-name arg)))
(`(major-mode . ,mode) (`(major-mode . ,mode)
(eq (eq
(buffer-local-value 'major-mode buffer) (buffer-local-value 'major-mode buffer)

View file

@ -7501,8 +7501,8 @@ Its value takes effect before processing the ACTION argument of
If non-nil, this is an alist of elements (CONDITION . ACTION), If non-nil, this is an alist of elements (CONDITION . ACTION),
where: where:
CONDITION is passed to `buffer-match-p', along with the buffer CONDITION is passed to `buffer-match-p', along with the name of
that is to be displayed and the ACTION argument of the buffer that is to be displayed and the ACTION argument of
`display-buffer', to check if ACTION should be used. `display-buffer', to check if ACTION should be used.
ACTION is a cons cell (FUNCTIONS . ALIST), where FUNCTIONS is an ACTION is a cons cell (FUNCTIONS . ALIST), where FUNCTIONS is an
@ -7559,12 +7559,16 @@ all fail. It should never be set by programs or users. See
(defun display-buffer-assq-regexp (buffer-or-name alist action) (defun display-buffer-assq-regexp (buffer-or-name alist action)
"Retrieve ALIST entry corresponding to buffer specified by BUFFER-OR-NAME. "Retrieve ALIST entry corresponding to buffer specified by BUFFER-OR-NAME.
This returns the cdr of the alist entry ALIST if the entry's This returns the cdr of the alist entry ALIST if the entry's
key (its car) and BUFFER-OR-NAME satisfy `buffer-match-p', using key (its car) and the name of the buffer designated by
the key as CONDITION argument of `buffer-match-p'. ACTION should BUFFER-OR-NAME satisfy `buffer-match-p', using the key as
have the form of the action argument passed to `display-buffer'." CONDITION argument of `buffer-match-p'. ACTION should have the
form of the action argument passed to `display-buffer'."
(catch 'match (catch 'match
(dolist (entry alist) (dolist (entry alist)
(when (buffer-match-p (car entry) buffer-or-name action) (when (buffer-match-p (car entry) (if (stringp buffer-or-name)
buffer-or-name
(buffer-name buffer-or-name))
action)
(throw 'match (cdr entry)))))) (throw 'match (cdr entry))))))
(defvar display-buffer--same-window-action (defvar display-buffer--same-window-action