unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#12673: 24.2; makefile-mode whitespace-cleanup
@ 2012-10-18 15:37 Arthur Azevedo de Amorim
  2020-12-07 17:04 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Arthur Azevedo de Amorim @ 2012-10-18 15:37 UTC (permalink / raw)
  To: 12673

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#12673: 24.2; makefile-mode whitespace-cleanup
  2012-10-18 15:37 bug#12673: 24.2; makefile-mode whitespace-cleanup Arthur Azevedo de Amorim
@ 2020-12-07 17:04 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-07 17:04 UTC (permalink / raw)
  To: Arthur Azevedo de Amorim; +Cc: 12673

Arthur Azevedo de Amorim <arthur.aa@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-07 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18 15:37 bug#12673: 24.2; makefile-mode whitespace-cleanup Arthur Azevedo de Amorim
2020-12-07 17:04 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).