emacs-devel
[Top][All Lists]
Advanced

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

Re: [ELPA] Add compat.el


From: Philip Kaludercic
Subject: Re: [ELPA] Add compat.el
Date: Fri, 08 Oct 2021 09:59:45 +0000

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Philip Kaludercic <philipk@posteo.net>
>> Date: Thu, 07 Oct 2021 20:49:12 +0000
>> 
>> >From Emacs 27 onwards, this works as expected:
>> 
>>         (string-replace "\377" "x" "a\377b")
>>         ;; => "axb"
>> 
>> internally, the compatibility function for string-replace uses
>> replace-regexp-in-string.
>> 
>> The same code, when evaluated by a version of Emacs older than 27 fails
>> to replace the character
>> 
>>         (string-replace "\377" "x" "a\377b")
>>         ;; => "a\377b"
>
> Why did you expect that to work?  What is the semantics of matching
> unibyte strings to multibyte strings? do you compare bytes or do you
> compare characters?  There are no "100% correct" answers for these
> questions.

The only reason I expect it is that it does work for Emacs 27.1 and
newer.

>> I couldn't find anything in NEWS.27 to indicate that something had
>> changed, so I wonder if there was a bug that was fixed?  Does anyone
>> know or remember why this behaviour changed?
>
> This is a gray area of regexp matching, and it keeps constantly
> changing in Emacs under the hood.  The changes are generally seen as
> "bugfixes" (though IMNSHO they aren't), and so they aren't called out
> in NEWS.  And what would you say there about such subtle changes,
> anyway?  So no one should expect it to work the same in different
> versions of Emacs.

True, but my concern here is to provide older versions of Emacs with the
same behaviour (for these newer functions, like string-search and
string-replace), so I do have to take it into consideration.

-- 
        Philip Kaludercic



reply via email to

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