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: Thu, 07 Oct 2021 20:49:12 +0000

Philip Kaludercic <philipk@posteo.net> writes:

> Hello again,
>
> I have been working on compat.el over the last week, and have written a
> number of tests. The source code has been uploaded here:
>
>        https://git.sr.ht/~pkal/compat
>
> The library should be usable in it's current state, but I'd be
> interested to hear from other people and developers too.  There might be
> missing functions or macros, edge cases that could be added to the
> tests, etc. that could be improved.

An interesting issue I found when testing compat.el with older versions
is that string-replace and string-search fail, due to the same kind of
issue.

>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"

For string-search, using string-match internally, the "unusual" byte
cannot be found:

       (string-search (string-to-multibyte "\377") "ab\377c")
       ;; => nil

whereas the expected answer is 2.

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?

-- 
        Philip Kaludercic



reply via email to

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