Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!mit-eddie!bbn!bbn.com!mesard
From: mesard@bbn.com (Wayne Mesard)
Newsgroups: comp.emacs
Subject: auto-mode-alist SUMMARY
Summary: set-auto-mode matches the full pathname, not the filename.
Message-ID: <26769@bbn.COM>
Date: 11 Jul 88 18:51:32 GMT
Sender: news@bbn.COM
Reply-To: mesard@BBN.COM (Wayne Mesard)
Organization: Bolt Beranek and Newman Inc., Cambridge MA
Lines: 53

In article <26352@bbn.COM> I wrote:
}I thought that the following in my auto-mode-alist, would match all
}filenames that begin with a dot:
}
}	("^\\." . fundamental-mode)
}
}It doesn't seem to match anything.  Bug?  Suggestions?

After wading through a slew of incorrect and partially correct messages
and follow-ups, some seemingly from people who once knew someone that
knew about regexp's, I received the explanation for this behavior from
Arndt Jonasson (arndt@zyx.SE):

> It turns out that the name against which the expression in auto-mode-alist
> is matched is the absolute path name, not just the filename component.
> Thus, since every absolute path name starts with '/', "^\\." will indeed
> match nothing. 

He then supplies a regexp that will match any pathname whose file
component starts with a dot:

>  "/\\.[^/]*$"

and one to match any file NOT containing a dot:

> "/[^\\./]*$"

> ['/' of course is relevant only for Unix. For VMS and other OS's, some
> other regular expressions must be used.]

So, this isn't a bug.  And it could be quite useful, at times, to have a
directory name influence the major mode.  But the documentation gives no
clue that it's using the full pathname.  In fact, it implies otherwise.

Hal Peterson  correctly states:
> Notice that backslashes are not necessary in the character set because
> dot loses its special meaning there.

I hesitate to mention it, at the risk of starting something similar to
the "unnecessary parens" war currently raging on comp.lang.c.  While
omitting the unnecesary backslashes improves readability (look Ma, a
readable regexp), the GEM says that it is for purely hysterical raisins
(as they say) that special characters are treated as ordinary ones where
their special meaning make no sense.

Thanks to all who took the time to respond.


-- 
unsigned *Wayne_Mesard();        MESARD@BBN.COM           BBN, Cambridge, MA
                                                          Not the Labs.
"I am catatonic.  And the drinks are on the house."
                                                     -DB