Skip to content

Instantly share code, notes, and snippets.

@dotemacs
Created November 24, 2012 16:12
Show Gist options
  • Save dotemacs/4140327 to your computer and use it in GitHub Desktop.
Save dotemacs/4140327 to your computer and use it in GitHub Desktop.
add-to-mode function
(defun add-to-mode (mode &rest files)
"Turn on MODE's syntax highlighting for FILES
where FILES is either a file or a regular expression"
(dolist (file files)
(add-to-list 'auto-mode-alist (cons file mode))))
(add-to-mode 'ruby-mode
"\\.gem\\(rc\\|spec\\)$"
"\\.\\(irbrc\\|rake\\|ru\\)$"
"\\(Cap\\|Gem\\|Rake\\|Puppet\\|Vagrant\\)file$")
(add-to-mode 'markdown-mode "\\.\\(md\\|markdown\\)$")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment