[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ELPA] New package: listen
From: |
Philip Kaludercic |
Subject: |
Re: [ELPA] New package: listen |
Date: |
Mon, 26 Feb 2024 07:47:40 +0000 |
Adam Porter <adam@alphapapa.net> writes:
> Hi Andreas,
>
> On 2/25/24 08:17, Andreas Schwab wrote:
>> On Feb 25 2024, Adam Porter wrote:
>>
>>>> @@ -942,10 +941,10 @@ extension.
>>>> Return one of symbols `vorbis', `opus', `flac', or `mp3'."
>>>> (let ((case-fold-search t))
>>>> - (cond ((string-match ".ogg$" filename) 'vorbis)
>>>> - ((string-match ".opus$" filename) 'opus)
>>>> - ((string-match ".flac$" filename) 'flac)
>>>> - ((string-match ".mp3$" filename) 'mp3)
>>>> + (cond ((string-match ".ogg\\'" filename) 'vorbis)
>>>> + ((string-match ".opus\\'" filename) 'opus)
>>>> + ((string-match ".flac\\'" filename) 'flac)
>>>> + ((string-match ".mp3\\'" filename) 'mp3)
>>>> (t nil))))
>>>
>>> According to the Elisp manual: "When matching a string instead of a
>>> buffer, ‘$’ matches at the end of the string or before a newline
>>> character." So it appears to be correct here
>> It should only match at the end of the string, not before a newline.
>
> As the manual says:
>
> ‘$’
> is similar to ‘^’ but matches only at the end of a line (or the end
> of the accessible portion of the buffer). Thus, ‘x+$’ matches a
> string of one ‘x’ or more at the end of a line.
>
> When matching a string instead of a buffer, ‘$’ matches at the end
> of the string or before a newline character.
^
this is the problem.
Since it is possible for file-names to contain newline characters,
matching the end of a line can result in false-positives:
(string-match-p
"\\.el$"
"foo.el\nbar.le")
;;=> 3
(string-match-p
"\\.el\\'"
"foo.el\nbar.le")
;;=> nil
(It's called the "manual", not the "infallible" (hehe) for a reason)
--
Philip Kaludercic on peregrine
- Re: [ELPA] New package: listen, (continued)
- RE: [External] : Re: [ELPA] New package: listen, Drew Adams, 2024/02/26
- Re: [External] : Re: [ELPA] New package: listen, Philip Kaludercic, 2024/02/26
- RE: [External] : Re: [ELPA] New package: listen, Drew Adams, 2024/02/26
- Re: [External] : Re: [ELPA] New package: listen, Adam Porter, 2024/02/26
- RE: [External] : Re: [ELPA] New package: listen, Drew Adams, 2024/02/26
- Re: [External] : Re: [ELPA] New package: listen, Stephen Berman, 2024/02/26
- Re: [ELPA] New package: listen, Andreas Schwab, 2024/02/25
- Re: [ELPA] New package: listen, Adam Porter, 2024/02/25
- Re: [ELPA] New package: listen,
Philip Kaludercic <=