Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How do I get Emacs to recognize new file extensions? For example if I have a .c file and I open it in Emacs, I get the correct syntax highlighting for C, but if I have a .bob file format (which I know to be C), how do I tell Emacs to interpret it in the same way as a .c file?

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

This is described on Emacs Beginner's Howto.

With the line

(setq auto-mode-alist (cons '("README" . text-mode) auto-mode-alist))

You tell emacs to enter "text-mode" if you open a file which is named README.

with

(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.htm$" . html-helper-mode) auto-mode-alist))

you tell emacs to type "html-helper-mode" if the file is named *.html or *.htm

on stackoverflow there is an example, that highligts *.emacs files as lisp.code:

(setq auto-mode-alist 
      (append '((".*\\.emacs\\'" . lisp-mode))
              auto-mode-alist))
share|improve this answer
    
Found the answer myself, but thanks for a more comprehensive answer :) –  NWS Nov 23 '11 at 10:30
add comment

I found the answer :

(setq auto-mode-alist (cons '("\\.bob" . c-mode) auto-mode-alist))
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.