GNU bug report logs - #12673
24.2; makefile-mode whitespace-cleanup

Previous Next

Package: emacs;

Reported by: Arthur Azevedo de Amorim <arthur.aa <at> gmail.com>

Date: Thu, 18 Oct 2012 15:48:01 UTC

Severity: normal

Found in version 24.2

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Arthur Azevedo de Amorim <arthur.aa <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2; makefile-mode whitespace-cleanup
Date: Thu, 18 Oct 2012 11:37:35 -0400
Hello,

I found a subtle bug while editing Makefiles using whitespace-cleanup
in my after-save-hook. I'm using emacs-24.2.

Suppose that I have the following in .emacs:

(setq-default indent-tabs-mode nil)
(add-hook 'after-save-hook 'whitespace-cleanup)

I open up emacs, visit a text file, and then save it.
whitespace-cleanup gets triggered. After that, I visit a Makefile.
Now, if I save the file, whitespace-cleanup converts tabs to 8 spaces.
Conversely, if I open first the Makefile, and then any other file,
whitespace-cleanup will convert 8 spaces in the text file to tabs.

I think I know where the problem is. whitespace.el has the following line

(defvar whitespace-indent-tabs-mode indent-tabs-mode)

When whitespace-cleanup is called for the first time on the text file,
the value of indent-tabs-mode is nil, because that is the default
value and text mode doesn't override it. When the Makefile is visited,
whitespace-indent-tabs-mode has already been defined, and so will
still be nil.

A way to fix the problem (I think) would be to remove
whitespace-indent-tabs-mode and simply use indent-tabs-mode instead.

I believe that functionality related to other buffer-local variables
would suffer from the same problem. For instance, the line below
defines whitespace-tab-width similarly.

-- 
Arthur Azevedo de Amorim




This bug report was last modified 4 years and 168 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.