allen@ssc.gov (Mike Allen) (10/29/90)
>>>>> 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