unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Patrick Mahan <plmahan@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Specifying a file in auto-mode-alist
Date: Fri, 23 Apr 2021 15:14:50 -0700	[thread overview]
Message-ID: <CAFDHx1Ju1Rgkj+h9_-mKNnejcOx3Y0h=N2f+_v2i0VGz5_Y8fQ@mail.gmail.com> (raw)
In-Reply-To: <jwvh7jw4r5w.fsf-monnier+emacs@gnu.org>

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	other threads:[~2021-04-23 22:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 20:25 Specifying a file in auto-mode-alist Patrick Mahan
2021-04-23 20:42 ` Óscar Fuentes
2021-04-23 21:42   ` Stefan Monnier
2021-04-23 22:14     ` Patrick Mahan [this message]
2021-04-23 22:09   ` Patrick Mahan
2021-04-23 22:23     ` Stefan Monnier

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='CAFDHx1Ju1Rgkj+h9_-mKNnejcOx3Y0h=N2f+_v2i0VGz5_Y8fQ@mail.gmail.com' \
    --to=plmahan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
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).