Customizing File Association in Emacs (based on file extension)

(0 votes, average 0 out of 5)

Occassionally it can be useful to have emacs automatically use a particular syntax highlighter based on file extension.  Typically this is useful when you want to use non-stnadard file extensions in your own environment.  You can get it to work by adding the following to your .emacs file (typically located in your home directory):

;; Use perl syntax highlighter for .foo files.
(setq auto-mode-alist (cons '(".*\.foo" . cperl-mode) auto-mode-alist))

The above code would use the cperl highlighter for all files ending in .foo.  

Partner Links:
Last Updated on Wednesday, 22 February 2012 12:18  
Related Articles

» How to Fix the PS2 Disc Read Error

Although the Playstation 2 is a system well-known for it's longevity and durability, the fact that it is over a decade old means that it inevitably will have a few issues.  The most common of which is the infamous disc read error.  This is characterized by entering a disc into the PS2, but instead of booting in the game, an error message comes up saying the disc could not be read or the disc was not recognized. There are several ways to fix it, listed below in order of least to most...

» Matplotlib IOError: Error While Writing to Output Stream

When using the Python Matplotlib library, Python may throw the following error:1IOError: error while writing to output streamCommonly this is caused because Python does not have access to the output stream -- in this case, usually some file that Matplotlib is attempting to write to.  This is typical when the Python script is being used on a web server.  For instance, the following code might not work if the directory "output" does not have write permissions on a...

» How to Rename a File or Directory from a Linux Terminal

The easiest way to rename a file from a linux terminal is simply to move it to the same directory with a different name.mv original_name.txt new_name.txt The example above will rename original_name.txt to new_name.txt.  The same syntax will also work for a directory.