Thanks for taking the time to go through it. I have tested it on a large set of R code files and it _does_ work for me (but I am sure it could break in unexpected ways, so I certainly don't hold to my code being perfect). Indentation of files with ~1000 LOC takes a few hundred milliseconds for me, so it's not that bad, but it certainly could be made better.

I tried to give a framework for things to be cleaner -- special cases where the format of a particular line gives us enough information to determine a sensible indentation, with a fall-back to the 'default' indentation rules (since those are rather obfuscated, and difficult to understand).