Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a theme for specific project (Projectile) in Emacs

Is there a possibility to set a specific color theme or just to hook on a specific project to run custom elisp?

So the idea is to automatically set a color theme or background-color when I open a file from a specific project (path)? E.g. I can work with multiple projects in different frames and instantly know where I am. May be this can written in .projectile file somehow ?

Here by frame I mean Frame not just a buffer.

like image 766
mico Avatar asked Oct 23 '13 08:10

mico


1 Answers

You can't do this as of now but there is a discussion going on here for something similar in the Projectile issue list. However you can use a .dir-locals.el file to get this done. I am guessing something similar would be implemented for projectile using .projectile file in the future once the devs decide upon it.

dir-locals.el is intended to set local variables for all files in that particular directory you could checkout the docs or this blog post for the details. It's not particularly designed to run elisp code (setting a theme is a load-theme function call I believe) for good reason. However you can use eval variable to work around this and emacs will ask you whether to run the code.

((nil . ((eval . (load-theme 'molokai 
                         )
           ))))

or you could do something even fancier according to the major modes.

 ((nil . ((indent-tabs-mode . t)
          (tab-width . 4)
          (fill-column . 80)))
  ;; Warn about spaces used for indentation:
  (haskell-mode . ((eval . (highlight-regexp "^ *"))))
  (c-mode . ((c-file-style . "BSD")))
  (java-mode . ((c-file-style . "BSD")))
  ("src/imported"
   . ((nil . ((change-log-default-name . "ChangeLog.local"))))))
like image 103
Diadara Avatar answered Sep 30 '22 17:09

Diadara