[comp.emacs] auto-mode-alist SUMMARY

mesard@bbn.com (Wayne Mesard) (07/12/88)

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 <hrp%fermi.CRAY.COM@UC.MSC.UMN.EDU> 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