Sometimes it feels that each project I work on has different indentation settings. Not quite true but still annoying. I don't know of a way to tell vim to auto-detect the indentation settings based on the current file (which, for X.Org projects wouldn't work anyway) but what has been incredibly useful is the vimdir script.
It simply scans the directory tree upwards to find a .vimdir file and loads the settings from there. So I keep files like this around:
setlocal noexpandtab shiftwidth=8 tabstop=8
The alternative is to add a snippet to the file itself but not every maintainer is happy with that.
/* vim: set noexpandtab tabstop=8 shiftwidth=8: */