whitespace-mode and cleanup on save off by default? #288

pparescasellas opened this Issue Mar 28, 2013 · 12 comments


None yet
5 participants

I thought whitespace-mode and cleanup on save was turned on by default but this doesn't seem to be the case. I have (unsuccessfully) tried to enable both by adding the following lines:

(setq prelude-whitespace t)
(setq prelude-clean-whitespace-on-save t)

How do I turn them on by default? Thanks


bbatsov commented Mar 30, 2013

That's odd. They should be on the default.

None of them are on by default when editing cpp files and only whitespace-mode is on when editing files with no extension. Org files have both on. Those are the ones I have checked.

These settings are off by default now, which personally I prefer. I used to have to disable them manually in my custom.el.

Unfortunately the hooks I add to prelude-prog-mode-hook are no longer called. Is this perhaps related?

tdavis commented May 2, 2013

Yep, noticed this too. For whatever reason, even when prelude-whitespace is t and prelude-enable-whitespace is called by a hook, before-save-hook remains nil.

henryr commented May 7, 2013

Also noticed this. I was able to fix by removing the 'local' flag to the save hook, but I'm not sure if that's the right solution.

(add-hook 'before-save-hook 'prelude-cleanup-maybe nil)


bbatsov commented May 8, 2013

whitespace cleanup is enabled by default only for modes that derive from prog-mode and text-mode. If you're using modes that don't derive from them you'll need to add the cleanup code manually. Making the hook non-local is not a very good idea since you'll lose the control over the modes it's enabled in.

I'm confused because I don't get whitespace-mode or cleanup on C++ mode which I believe derives from prog-mode.


bbatsov commented May 8, 2013

There is a catch and it's called indent-tabs-mode. Someone submitted a PR a while back enabling indent-tabs-mode in c-mode and this overrides whitespace-cleanup (as mentioned in its documentation). I can disable indent-tabs-mode and that would fix your problem. If you had mention c-mode in the beginning I would have momentarily told you that :-)

tdavis commented May 8, 2013

Well, the same can be said of python-mode as well. Try this exercise:

  1. Open Python (Ruby, Javascript, whatever) file.
  2. Note the value of before-save-hook is nil.
  3. Execute (add-hook 'prog-mode-hook 'prelude-enable-whitespace)
  4. Revert buffer
  5. Note value of before-save-hook is no longer nil.

bbatsov commented May 8, 2013

Here's a ruby-mode example:

before-save-hook is a variable defined in `files.el'.
Its value is (prelude-cleanup-maybe ruby-mode-set-encoding t)
Original value was nil
Local in buffer not_spec.rb; global value is nil

tdavis commented May 8, 2013

Ah. Apparently I missed out on the whole "prelude-modules" thing, so I
had no prog-mode hooks installed. I hadn't updated Prelude since around
December and I guess the module stuff changed again.


bbatsov commented May 8, 2013

Yep, it was changed. This time around I plan things to stay more or less like they currently are for the foreseeable future. The "modules as packages" was a pretty bad idea in retrospect.

bbatsov closed this May 19, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment