Skip to content

Instantly share code, notes, and snippets.

@johnfredcee
Created December 3, 2012 17:01
Show Gist options
  • Select an option

  • Save johnfredcee/4196339 to your computer and use it in GitHub Desktop.

Select an option

Save johnfredcee/4196339 to your computer and use it in GitHub Desktop.
Emacs - protect your code from accidental editing
(defun make-some-files-read-only ()
"when file opened is of a certain mode, make it read only"
(when (memq major-mode '(c++-mode python-mode c-mode actionscript-mode unrealscript-mode lisp-mode))
(toggle-read-only 1)))
(add-hook 'find-file-hook 'make-some-files-read-only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment