Colourful project-root

So project-root has had anything support for a while but the other day I hacked in a feature which allowed the user to highlight different parts of a project in the anything buffer.

The screenshot shows files that are in /t (tests) as green and blocks (an internal thing) which I need to open quite often in another face (font-lock-keyword).

This comes in really handy because I can apply the same colour strategy to all projects meaning I don’t have to read the entire filename when the anything buffer is littered with similar looking files. I also dim filenames which I care less about (but are still important enough to include in the search).

The config looks something like this:

1
2
3
4
5
6
7
8
9
10
'(("Dynamite"
   :anything-highlight
   (("Dynamite/Schema/DB/" . widget-inactive)
    ("^t/.+/\\([[:alnum:]]+\.pm\\)" . diff-added-face)
    ("Dynamite/Interface/Block/\\([[:alnum:]]+\.pm\\)"
     . font-lock-keyword-face))
   :root-contains-files ("lib" "t" "conf/dynamite_common.xml")
   :bookmarks ("lib/Dynamite/Controller/iPlayer/Widget"
               "lib/Dynamite/Interface/Block"
               "data/templates"))

So the first group is highlighted in the specified face. If there is no grouping then the entire string is highlighted.


blog comments powered by Disqus