bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62417: ; Regression: 59ecf25fc860 is the first bad commit


From: Philip Kaludercic
Subject: bug#62417: ; Regression: 59ecf25fc860 is the first bad commit
Date: Sat, 25 Mar 2023 13:17:40 +0000

Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: 62417@debbugs.gnu.org
>> From: João Távora <joaotavora@gmail.com>
>> Date: Fri, 24 Mar 2023 19:48:35 +0000
>> 
>> If the previous explanation is somehow hard to understand, here's a
>> hopefully simpler one with a repro which doesn't require SLY.  In Emacs
>> 28 the docstring for `display-buffer-alist` states (emphasis mine):
>> 
>>    If non-nil, this is an alist of elements (CONDITION . ACTION),
>>    where:
>>     
>>     CONDITION is either a regexp matching buffer names, or a
>>      function that takes two arguments - a buffer name and the
>>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>      ACTION argument of `display-buffer' - and returns a boolean.
>> 
>> In Emacs 29, the docstring was changed to state:
>> 
>>     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
>>       `display-buffer', to check if ACTION should be used.
>> 
>> Any code that was written for the Emacs 28 contract in mind like, for
>> example:
>> 
>>    (defun foop (buffer-name _alist) (string-match "foop" buffer-name))
>> 
>>    (add-to-list 'display-buffer-alist '(foop . display-buffer-other-frame))
>> 
>> Will now fail with an obscure error message.  I've checked "Incompatible
>> Lisp Changes in Emacs 29.1" in etc/NEWS and could not find a mention to
>> this, so I assume it was not intentional.
>> 
>> So it is most clearly a regression.
>
> There's something missing in the above description, since
> buffer-match-p accepts a function as its CONDITION argument, and calls
> that function with the buffer and ACTION.  

We would have to call the function with the buffer name instead of the
buffer object.  So the `buffer-match-p' fix would look like this:

diff --git a/lisp/subr.el b/lisp/subr.el
index 99ddd813867..3210ab05702 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -7140,8 +7140,8 @@ buffer-match-p
                        (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-name buffer))
+                         (funcall condition (buffer-name buffer) arg)))
                       (`(major-mode . ,mode)
                        (eq
                         (buffer-local-value 'major-mode buffer)
I don't think I am a fan of this, as most of the time a buffer is more
immediately useful.  Perhaps João's initial change would be better in
that case, for the sake of backwards compatibility?  Or does it make
sense to mention this as an incompatible lisp change?

>                                            So it sounds like code
> written for Emacs 28 should still work.  What is missing here that
> explains the breakage?

-- 
Philip Kaludercic

reply via email to

[Prev in Thread] Current Thread [Next in Thread]