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

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

Re: Is this comment in my .emacs correct?


From: William Payne
Subject: Re: Is this comment in my .emacs correct?
Date: Fri, 20 Aug 2004 18:18:13 +0200

"Kevin Rodgers" <ihs_4664@yahoo.com> wrote in message 
41261839.20804@yahoo.com">news:41261839.20804@yahoo.com...
> William Payne wrote:
> > From my .emacs-file:
> >
> > (setq auto-mode-alist
> >       (append
> >        (list
> > ; Must use Makefile$ and not just Makefile or you will get makefile mode 
> > for
> > any
> > ; type of file in a directory with the string makefile in it
> >         '("\\Makefile$" . makefile-mode)         )
> >        auto-mode-alist
> >        )
> >       )
> >
> > Is the comment correct?
>
> Almost.  You do need to anchor the "Makefile" string, because the
> auto-mode-alist entries are matched against the entire file name
> (`C-h v buffer-file-name' for an example).  But "$" is not the best
> anchor, because it can also match a newline in the path; that's an
> admittedly unusual case, but it'd be better and consistent with the
> other entries if you used "\\'".  Also, you might want to anchor the
> beginning of the file name; but the default entries don't provide much
> guidance since there are examples with no anchor, some with just "/",
> and some with "\\(/\\|\\`\\)".
>
> (setq auto-mode-alist
>       (cons '("\\(\\`\\|/\\)Makefile\\'" . makefile-mode)
>             auto-mode-alist))
>
> -- 
> Kevin Rodgers
>

Thanks for the reply, Kevin. I wanted to make sure I load makefile-mode only 
when dealing with a file named Makefile and not when the path to the file 
contained the string Makefile. Your version seems to work, thanks.

/ WP 




reply via email to

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