Sometimes you want to open in Emacs a source code file, and you want to see it formatted nicely (e.g. as you would see a .c or .java file) but the file has some totally different file extension.

In my example I wanted to view a MQL file (specialized programming language for trading), whose syntax is very much like C but the extension is .mq4 so Emacs does not activate it’s c-mode font-lock feature for these files and soe the code looks dull and is hard to read.


Add this to your .emacs file:

(setq auto-mode-alist (cons '("\.mq4$". c++-mode) auto-mode-alist))

This will add the .mq4 file extension to Emacs’s global list of files to treat as C language files.



Leave a Reply

Your email address will not be published. Required fields are marked *

Set your Twitter account name in your settings to use the TwitterBar Section.