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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12673 in the body.
You can then email your comments to 12673 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#12673; Package emacs. (Thu, 18 Oct 2012 15:48:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Arthur Azevedo de Amorim <arthur.aa <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 18 Oct 2012 15:48:02 GMT) Full text and rfc822 format available.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12673; Package emacs. (Mon, 07 Dec 2020 17:06:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Arthur Azevedo de Amorim <arthur.aa <at> gmail.com>
Cc: 12673 <at> debbugs.gnu.org
Subject: Re: bug#12673: 24.2; makefile-mode whitespace-cleanup
Date: Mon, 07 Dec 2020 18:04:50 +0100
Arthur Azevedo de Amorim <arthur.aa <at> gmail.com> writes:

> Suppose that I have the following in .emacs:
>
> (setq-default indent-tabs-mode nil)
> (add-hook 'after-save-hook 'whitespace-cleanup)

[...]

> 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.

(This bug report unfortunately got no response at the time.)

whitespace-indent-tabs-mode was removed at some point after this bug
report, so I'm going to go ahead and guess that this bug has been fixed
over the years, and I'm closing this bug report.  If this is still an
issue, please respond to the debbugs address and we'll reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 12673 <at> debbugs.gnu.org and Arthur Azevedo de Amorim <arthur.aa <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 07 Dec 2020 17:06:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 05 Jan 2021 12:24:08 GMT) Full text and rfc822 format available.

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.