all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* why auto-mode-alist's regex ends in \\'
@ 2008-07-07 23:22 Xah
  2008-07-07 23:58 ` Lennart Borgman (gmail)
       [not found] ` <mailman.14358.1215475153.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Xah @ 2008-07-07 23:22 UTC (permalink / raw)
  To: help-gnu-emacs

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/^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why auto-mode-alist's regex ends in \\'
  2008-07-07 23:22 why auto-mode-alist's regex ends in \\' Xah
@ 2008-07-07 23:58 ` Lennart Borgman (gmail)
       [not found] ` <mailman.14358.1215475153.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2008-07-07 23:58 UTC (permalink / raw)
  To: Xah; +Cc: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why auto-mode-alist's regex ends in \\'
       [not found] ` <mailman.14358.1215475153.18990.help-gnu-emacs@gnu.org>
@ 2008-07-08  1:47   ` Barry Margolin
  2008-07-09  0:50   ` Xah
  1 sibling, 0 replies; 4+ messages in thread
From: Barry Margolin @ 2008-07-08  1:47 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1054 bytes --]

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 ***


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why auto-mode-alist's regex ends in \\'
       [not found] ` <mailman.14358.1215475153.18990.help-gnu-emacs@gnu.org>
  2008-07-08  1:47   ` Barry Margolin
@ 2008-07-09  0:50   ` Xah
  1 sibling, 0 replies; 4+ messages in thread
From: Xah @ 2008-07-09  0:50 UTC (permalink / raw)
  To: help-gnu-emacs

Lennart Borgman wrote:
>    (info "(elisp) Syntax of Regexps")
>
> \' matches end of string
> $ matches end of line

Thanks! That's a good one to catch.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-07-09  0:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-07 23:22 why auto-mode-alist's regex ends in \\' Xah
2008-07-07 23:58 ` Lennart Borgman (gmail)
     [not found] ` <mailman.14358.1215475153.18990.help-gnu-emacs@gnu.org>
2008-07-08  1:47   ` Barry Margolin
2008-07-09  0:50   ` Xah

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.