Friday, February 24, 2012

Emacs Tip: Change Background colour depending on File mode

From the gnu.emacs.help mailing list, here's a nice tip by Kevin Rodgers that might be useful for those who need visual reminders when working on read only files.  Adding the following to your .emacs, would change the background to yellow in this case, which, of course you can modify.

(add-hook 'find-file-hooks

 (lambda ()
   (when buffer-read-only
     (set-background-color "yellow"))))