The latest approach is to try to get different behavior based on whether the indentation is line-related or region-related.
Emacs provides two variables that can be set to functions that handle each type of indentation:
indent-region-function, andindent-line-function
The idea is to provide an appropriate function for each of these variables.
I've tried out the code below along with the following commands: