]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix accidental backward-incompatible change (bug#62417)
authorJoão Távora <joaotavora@gmail.com>
Mon, 27 Mar 2023 11:25:16 +0000 (12:25 +0100)
committerJoão Távora <joaotavora@gmail.com>
Mon, 27 Mar 2023 11:59:14 +0000 (12:59 +0100)
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.

lisp/subr.el
lisp/window.el

index c73643f6d2bcaa97f7ad859b73b57b7a7206d152..8d27c831c96158d9df8e559e6b6bcb9d309c94cb 100644 (file)
@@ -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)
index f6ddae854ad7233cbe6204f32df4eee175040ddd..4bdc26571f59ea201ab06e371a6f9ec25a7a2fee 100644 (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),
 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