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

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

Re: why auto-mode-alist's regex ends in \\'


From: Barry Margolin
Subject: Re: why auto-mode-alist's regex ends in \\'
Date: Mon, 07 Jul 2008 21:47:22 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <mailman.14358.1215475153.18990.help-gnu-emacs@gnu.org>,
 "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> wrote:

> Xah wrote:
> > By default, auto-mode-alist has a element:
> > 
> >  ("\\.png\\'" . image-mode)
> > 
> > why is it not the following instead?
> > 
> >  ("\\.png$" . image-mode)
> > 
> > I can't see how file name would end in a “'”, but apparently all
> > regexes there is like that. Emacs's doc node Choosing Modes doesn't
> > seems to explain this.
> > 
> > Thanks.
> > 
> >   Xah
> > ∑ http://xahlee.org/
> 
> See
> 
>    (info "(elisp) Syntax of Regexps")
> 
> \' matches end of string
> $ matches end of line

99.99% of the time either syntax will work in this context.  It can fail 
if you have filenames containing newline -- a file named 
"foo.png<newline>bar" would go into image-mode if the second version 
were used.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


reply via email to

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