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: Stefan Monnier
Subject: Re: Is this comment in my .emacs correct?
Date: Fri, 20 Aug 2004 16:38:10 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>> '("\\Makefile$" . makefile-mode)         )
[...]
> Not quite.  You'll get makefile mode for any pathname that contains the 
> string "\Makefile" in it.  So it will use this mode for something like 
> "C:\Data\Makefiles\README.txt", but not 
> "C:\Data\My_Makefiles\README.txt".

Still not quite: the string "\\Makefile$" turns into the regexp \Makefile$
but the `\M' is interpreted as just `M' (i.e. the backslash is ignored:
it should be flagged as an error, really).

> The $ matches the end of the pathname.

And it also matches a newline embedded in the pathname (e.g. if a file or
directory's name spans two or more lines).  Use the regexp operator \' if
you only want to match the end of the pathname.

So what the original regexp probably meant was: "\\\\Makefile\\'".
But note that Emacs will very often turn a \ into a / in your pathnames.
So maybe "[\\/]Makefile\\'" is better.

But in any case, there is already an entry

 ("\\(M\\|m\\|GNUm\\)akefile\\'" . makefile-mode)

in auto-mode-alist in not too ancient Emacsen, so you can simply remove the
whole thing from your .emacs file.


        Stefan


reply via email to

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