Question

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.

Was it helpful?

Solution

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"))))))

OTHER TIPS

The latest projectile (projectile-20140716.416) now supports hooking in arbitrary elisp after project switch, elisp such as:

  (load-theme 'zenburn t)

An example script that exploits the hook is here: http://github.com/jfeltz/projectile-load-settings

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top