14 December 2008
Proel - Project support for Emacs
One of the most fundamental features that Emacs is missing among all the goodness available for programmers is the support for handling software projects ie. the way TextMate or IDEs does this. Not having a quick way to navigate between files, classes, methods and other symbols starts to significantly suck if you’re working with bigger bases of source code. Because of this, a year or two ago I rolled two screen pages of Elisp or so, to make the basic operations I want to have available project-wide available. It served me very well ever since than, but it was a dirty hack and I really didn’t knew much Lisp at that time. Recently, seeing some other attempts at solving this problem, I decided to cleanup and extend my solution a little bit and make it available for the general public. So the proel package was born.
Proel makes one fundamental assumption - you have a set of dedicated directories for your software projects (ie. ~/code/work or ~/code/own), and each project has a single root directory in one of the projects directory, which name is also the name of the project (ie. ~/code/work/boring-app or ~/code/own/fun-app).
If you’re configuration is meeting this assumption, proel enables you to effectively open one of the projects and than to find files in the project using fuzzy matching (like in TextMate) ie. you can type SemaAn.g to open SemanticAnalysis.g. You have to have the wonderful “anything” package for that (see also here), and “fuzzy-match”, the library doing the string matching.
Proel also arguments the find-file function, so whenever you open a file “manually”, the project gets recognized. If the project directory contains the “TAGS” or “cscope.out” files, proel will also automatically visit the tags table or load the cscope database. You can also use the ‘proel-vc-in-project’ command to open up the Emacs version control status interface in projects directory (SVN and git are currently supported, but you can easily add your preffered VC) or ‘proel-grep-in-project’ to do a recursive grep somewhere in the project directory.
This is now one of the most producitivity-enhancing packages I have installed (together with anything, psvn, git.el, ediff and some other stuff I rolled on my own I will relase one day hopefully). The only thing I miss is being able to locate symbols/definitions using
anything and fuzzy matching the way locating files work, but I hope I will be able to work out that one too. Also, for other people, another way of recognizing projects could be desirable (ie. by detecting the topmost parent directory of the current file has a “Makefile” or “build.xml” like eproject).
A picture is worth a thousand words, so here you can see how it works in practice:
(Download the original, sharp video in Theora here)
And here’s a sample .emacs I use in the screencast:
(add-to-list 'load-path "/home/sztywny/.elisp") (add-to-list 'load-path "/home/sztywny/.elisp/git") (require 'anything) (require 'git) (require 'proel) (require 'xcscope) (tool-bar-mode nil) (scroll-bar-mode nil) (setq cscope-do-not-update-database t grep-find-template "find . -type f -print0 | xargs -0 -e grep -nH -e " anything-sources '(proel-anything-projects proel-anything-current-project-files))
You will probably want to customize other things too, just look through the source code to get an idea what variable controls what
aspect of proels behaviour. I hope you will like it :)
Comments ():
Neeraj, 9 July 2011, 8:57 pm
Does this work on a windows machine? I tried setting a project path in proel-dirs-with-projects to path like c:\project and also /project it always complains that proel-project-path accessing non-proel-project
stiff, 9 July 2011, 11:05 pm
You would probably have to go through the source code and replace “/” everywhere with “\”, I probably should have done it in a OS-independent way, but I don’t use Emacs on Windows and this thing is a few years old now. I am working on improving this whole thing quite a bit and I hope to release a new version in about a month, maybe I will fix it then.
phillies tickets, 22 July 2011, 2:43 pm
Good support in my opinion is one of the most important things needed in a provider, and also no down time but that is a hard thing to get some times.