33: How do I make Emacs use a certain major mode for certain files? If you want to use XXX mode for all files which end with the extension `.YYY', this will do it for you: (setq auto-mode-alist (cons '("\\.YYY\\'" . XXX-mode) auto-mode-alist)) Otherwise put this somewhere in the first line of any file you want to edit in XXX mode: -*-XXX-*-