help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Specifying a file in auto-mode-alist


From: Patrick Mahan
Subject: Re: Specifying a file in auto-mode-alist
Date: Fri, 23 Apr 2021 15:14:50 -0700

On Fri, Apr 23, 2021 at 2:52 PM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> >> (add-to-list 'auto-mode-alist (quote("build*\\.log'" .
> compilation-mode)))
> > ____________________________________________________^
>
> Here you needed to replace ' with \\'
>
> >> When I edit a file say 'build.log' it does not enable compilation mode.
> >>
> >> I tried -
> >>
> >> (add-to-list 'auto-mode-alist (quote("build*\\'" . compilation-mode)))
> > ________________________________________________^
> >
>
> And here you just forgot the \\.log
>
> > Why the ' ?
> >
> > Try this regexp: "^[Bb]uild.*\\.log$"
>
> No, he was on the right path.
>
> The correct regexp construct to match the end of a string is \' (which
> inside a string ends up looking like \\' since the backslash needs to be
> escaped), whereas the $ you're recommending matches both the end of
> a string and an end of *line*, so it can mis-match with a file named
> "build.log\nhello.svg".
>
>
Yes!  Success!  Thanks Stefan!  Changing it to escape the ' makes it work
now.

Patrick


reply via email to

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