Xref: utzoo gnu.emacs.help:162 comp.emacs:9397 Path: utzoo!telly!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ssc.gov!allen From: allen@ssc.gov (Mike Allen) Newsgroups: gnu.emacs.help,comp.emacs Subject: autoload Message-ID: <9010291517.AA24814@ssc.gov> Date: 29 Oct 90 15:17:02 GMT References: <1990Oct25.201758.21004@odin.corp.sgi.com> Sender: daemon@tut.cis.ohio-state.edu Reply-To: allen@sscvx1.ssc.gov Followup-To: gnu.emacs.help Distribution: gnu Organization: GNUs Not Usenet Lines: 40 >>>>> On 25 Oct 90 20:17:58 GMT, sgi!shinobu!odin!milt@cis.ohio-state.edu (Milton Tinkoff) said: Milton> How can I get c++-mode to autoload based on the extension of the file I'm Milton> editing? If I type 'emacs filename.c++' I want c++-mode to be loaded. Milton> I have the following in my .emacs: Milton> (setq load-path (append load-path '("/usr/local/src/emacs/lisp/local"))) Milton> (setq auto-mode-alist Milton> (append '(("\\.c$" . c-mode) Milton> ("\\.h$" . c-mode) Milton> ("\\.C$" . c++-mode) Milton> ("\\.H$" . c++-mode) Milton> ("\\.c++$" . c++-mode) Milton> ("\\.h++$" . c++-mode)) Milton> auto-mode-alist)) Milton> (autoload 'c++-mode "c++-mode.elc" "c++ mode" t nil) Milton> If I do a M-x c++mode it loads fine. What am I doing wrong? I had that problem for a while, until I remembered that '+' has special meaning to regular expressions! Do this: ... (setq auto-mode-alist (cons '("\\.h\\+\\+$" . c++-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.c\\+\\+$" . c++-mode) auto-mode-alist)) ... -Mike =============================================================================== Michael E. Allen Mail Stop 1046 SSC Laboratory 2550 Beckleymeade Ave. Dallas, TX 75237 (214)708-3031 al tadin et khaverkha 'ad shetagi'a limkomo