[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ELPA] Add compat.el
From: |
Eli Zaretskii |
Subject: |
Re: [ELPA] Add compat.el |
Date: |
Fri, 08 Oct 2021 08:56:14 +0300 |
> 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.
> For string-search, using string-match internally, the "unusual" byte
> cannot be found:
>
> (string-search (string-to-multibyte "\377") "ab\377c")
> ;; => nil
Because it isn't a byte, internally.
> 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.
Re: [ELPA] Add compat.el, Mattias EngdegÄrd, 2021/10/08
Re: [ELPA] Add compat.el, Philip Kaludercic, 2021/10/15