Could you take a look at this bug report? Thanks:
"Craig Falls" <cfalls@janestcapital.com> wrote:
There is a problem with whitespace-cleanup, when called before
whitespace-turn-on. The buffer-local variable
whitespace-indentation-regexp doesn't get updated to correspond to the
buffer-local value of indent-tabs-mode. This means that even if
indent-tabs-mode is nil, a line with text following a single tab
character will not be converted into a line of text following 8 space
characters when whitespace-cleanup is called. There is a simple
work-around -- just turn whitespace on and off again to set the
buffer-local variables:
(defun my-whitespace-cleanup ()
"Fixes a bug in whitespace-cleanup in which buffer-local
indent-tabs-mode is not respected."
(interactive)
(whitespace-turn-on) ;; sets buffer-local variables
(whitespace-turn-off) ;; don't actually want the mode to be on
(whitespace-cleanup))
Here are instructions to replicate the problem:
Start up with no .emacs. Set indent-tabs-mode to nil. Make sure
'indentation is in whitespace-style. Insert a tab character into a
buffer with no spaces after it, e.g. the line could be "\tfoo". Run
whitespace-cleanup in the buffer. Note that the tab character is still
there. Now run my-whitespace-cleanup. Note that the tab character has
been replaced by spaces.
The fact that indent-tabs-mode is buffer-local is important. For
example, makefile-mode sets it to true since tabs are a necessary part
of the syntax of make files.