From: João Távora Date: Mon, 27 Mar 2023 11:25:16 +0000 (+0100) Subject: Fix accidental backward-incompatible change (bug#62417) X-Git-Tag: emacs-29.0.90~76 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=edc460e3b6c38eee97dde847987b2c29dd134653;p=emacs.git Fix accidental backward-incompatible change (bug#62417) This code used to work, but with the change of 59ecf25fc860 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. --- diff --git a/lisp/subr.el b/lisp/subr.el index c73643f6d2b..8d27c831c96 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -7069,7 +7069,7 @@ CONDITION is either: - the symbol t, to always match, - the symbol nil, which never matches, - 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, - a cons-cell, where the car describes how to interpret the cdr. The car can be one of the following: @@ -7095,8 +7095,8 @@ CONDITION is either: (string-match-p condition (buffer-name buffer))) ((pred functionp) (if (eq 1 (cdr (func-arity condition))) - (funcall condition buffer) - (funcall condition buffer arg))) + (funcall condition buffer-or-name) + (funcall condition buffer-or-name arg))) (`(major-mode . ,mode) (eq (buffer-local-value 'major-mode buffer) diff --git a/lisp/window.el b/lisp/window.el index f6ddae854ad..4bdc26571f5 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -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), where: - CONDITION is passed to `buffer-match-p', along with the buffer - that is to be displayed and the ACTION argument of + CONDITION is passed to `buffer-match-p', along with the name of + the buffer that is to be displayed and the ACTION argument of `display-buffer', to check if ACTION should be used. 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) "Retrieve ALIST entry corresponding to buffer specified by BUFFER-OR-NAME. 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 -the key as CONDITION argument of `buffer-match-p'. ACTION should -have the form of the action argument passed to `display-buffer'." +key (its car) and the name of the buffer designated by +BUFFER-OR-NAME satisfy `buffer-match-p', using the key as +CONDITION argument of `buffer-match-p'. ACTION should have the +form of the action argument passed to `display-buffer'." (catch 'match (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)))))) (defvar display-buffer--same-window-action