From: Philip Kaludercic <philipk@posteo.net>
To: Adam Porter <adam@alphapapa.net>
Cc: Andreas Schwab <schwab@linux-m68k.org>,
emacs-devel <emacs-devel@gnu.org>
Subject: Re: [ELPA] New package: listen
Date: Mon, 26 Feb 2024 07:47:40 +0000 [thread overview]
Message-ID: <871q8z8y5f.fsf@posteo.net> (raw)
In-Reply-To: <e292fa88-9fc2-4cb0-bc1c-baea11c257dc@alphapapa.net> (Adam Porter's message of "Sun, 25 Feb 2024 21:46:46 -0600")
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
prev parent reply other threads:[~2024-02-26 7:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-25 7:28 [ELPA] New package: listen Adam Porter
2024-02-25 11:43 ` Philip Kaludercic
2024-02-25 13:14 ` Adam Porter
2024-02-25 13:45 ` Philip Kaludercic
2024-02-26 4:15 ` Adam Porter
2024-02-26 8:09 ` Philip Kaludercic
2024-02-26 8:50 ` Adam Porter
2024-02-26 10:13 ` Philip Kaludercic
2024-02-26 14:51 ` Adam Porter
2024-02-26 15:26 ` Philip Kaludercic
2024-02-26 15:45 ` Adam Porter
2024-02-26 17:17 ` [External] : " Drew Adams
2024-02-26 17:21 ` Philip Kaludercic
2024-02-26 17:43 ` Drew Adams
2024-02-26 18:07 ` Adam Porter
2024-02-26 21:18 ` Drew Adams
2024-02-26 22:14 ` Stephen Berman
2024-02-25 14:17 ` Andreas Schwab
2024-02-26 3:46 ` Adam Porter
2024-02-26 7:47 ` Philip Kaludercic [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871q8z8y5f.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=adam@alphapapa.net \
--cc=emacs-devel@gnu.org \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).