Don't highlight tabs when indent-tabs-mode is set to t
luismbo opened this issue · 9 comments
I agree that tabs are evil, but when indent-tabs-mode
is set to t
, I think ethan-wspace-mode
shouldn't highlight tabs. Do you agree?
FWIW, here's what I'm using right now:
(add-hook 'ethan-wspace-mode-hook
(lambda ()
(when indent-tabs-mode
(setq ethan-wspace-errors (remove 'tabs ethan-wspace-errors)))))
Perhaps this could be the default behavior?
That's interesting. Can you tell me a little bit more about your use case? Do you normally use indent-tabs-mode
? For me tabs are only useful as syntactic tokens in Makefiles. In that case, I would want to see when lines didn't have tabs in them. Highlighting tabs in that case is helpful to me because I can see which lines are different. I think maybe the most optimal behavior would therefore be to highlight lines that have space indentation instead of tabs (or, instead, clean them to always have tabs). What do you think?
Some projects I work on indent using tabs (yes, they are wrong, I know! :-)), so indent-tabs-mode is set to t there. Cleaning/highlighting spaces would be useful when indenting with tabs, yes!
Sorry for waiting almost a year to fix this, but it should be fixed in current master. I decided to just take the easy fix that you proposed rather than trying to figure out how to define invalid spaces in a file where indent-tabs-mode
was true. Please don't hesitate to reopen if it doesn't work :)
HAA! this borke my workflow ;/ ( https://xkcd.com/1172/ )
I've been happy ethan-wspace used for years, and it had worked almost perfectly -- I've taken some updates every now and then and I've got some small improvements (small as it was aready so good).
I like tabs -- it makes my cursor move (8x) faster when using left-right arrow keys.
I have indent-tabs-mode set.
Last few days, in new installation I've apparenlty downloaded new ethan-wspace.el (for some reason,
I usually glone my configuration repo and it comes that way), and I've experienced strange thing in
a file that uses only spaces for indentation -- saved file has tabs, and I don't see highlighting -- had
to untabify those multiple times and M-x ethan-wspace-clean-tabs-mode didn't help..
Finally I got here to look around and noticed the latest commit... and based on that after doing:
- (when indent-tabs-mode
+ (when (and nil indent-tabs-mode)
Things work as the used to be -- if file initially had tabs it highlights and keeps those -- without
initial tabs it doesn't highlight(*) those and removes tabs when saving...
I guess setting indent-tabs-mode to nil might also get the old behaviour, but I don't like to emphasize
indentation w/o tabs where not generally suggested...
(*) although I'd like to see tabs always highlighted, but haven't got around to configure that --
I also (almost) always when I do want tabs to a new file I have to trick those in and then reload
the file to make ethan-wspace to keep the tabs. I tried again -- M-x ethan-wspace-clean-tabs-mode
did not do what I expected ;/
Anyway, a rant to ages-ago closed issue. I guess I'll be using "First actual release" for the next decade or so... 8D
Thanks again for ethan-wspace!
Hi, thanks for your feedback. It sounds like you want tabs to be always highlit and never cleaned? Unfortunately I don't think we support that yet. I'm not sure it's a good fit for ethan-wspace
. There are a bunch of highlight-whitespace customizations shown on EmacsWiki, maybe one of those will be appropriate for you?
As for breaking your workflow, it's easy enough to customize the behavior of ethan-wspace-errors
-- the README in that commit contains directions that might work. However, at best that will just restore the old behavior -- either cleaning or highlighting, and since you seem to never want cleaning, you still might be better served by one of the other customizations listed above. Good luck achieving the setup you want!
I sure want cleaning (cleaning meaning tabs-to-spaces) when I find-file an existing file that doesn't have tabs so that I don't introduce tabs there.
The only thing I'd sometimes like to behave differently is that when I create new file and I'd like to have tabs there ethan-wspace cleans those away, until I do some tricks... But that is such a small pain that
I haven't bothered to do anything with it :D. If it were necessary I could elisp it in any day...
Yes, I think what you want is to write another kind of error type. Feel free to write one. I don't expect the interface for error types to change any time soon, so your workflow should be safe for a while :)
Actually, this has been working fine for me for a while:
@@ -800,8 +800,7 @@
(setq require-final-newline nil))
(when indent-tabs-mode
- (setq ethan-wspace-errors
- (remove 'tabs ethan-wspace-errors)))
+ (ethan-wspace-highlight-tabs-mode))
(run-hooks 'ethan-wspace-errors-in-buffer-hook)
(ethan-wspace-update-buffer)
Now I see tabs highlighted and haven't noticed any surprises. If I could explain that better
(why I think that is good idea I'd submit a pull request, but since not...)
Thanks (from happy ethan-wspace user since 2012)