What I use is here: <a href="http://philh.net/smart-tab.el" rel="nofollow">http://philh.net/smart-tab.el</a><p>Which is a (very slightly) modified version of what I foud here: <a href="http://bytes.inso.cc/wp/2009/01/07/dot-emacs-smarter-indentation-with-tabs-and-spaces/" rel="nofollow">http://bytes.inso.cc/wp/2009/01/07/dot-emacs-smarter-indenta...</a><p>This seems to be a more language-agnostic approach: <a href="http://www.emacswiki.org/emacs/SmartTabs" rel="nofollow">http://www.emacswiki.org/emacs/SmartTabs</a>