Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't highlight tabs when indent-tabs-mode is set to t #31

Closed
luismbo opened this issue Apr 13, 2016 · 9 comments
Closed

Don't highlight tabs when indent-tabs-mode is set to t #31

luismbo opened this issue Apr 13, 2016 · 9 comments

Comments

@luismbo
Copy link

luismbo commented Apr 13, 2016

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?

@luismbo
Copy link
Author

luismbo commented Apr 13, 2016

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?

@glasserc
Copy link
Owner

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?

@luismbo
Copy link
Author

luismbo commented Apr 13, 2016

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!

@glasserc
Copy link
Owner

glasserc commented May 7, 2017

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 :)

@domo141
Copy link

domo141 commented Mar 6, 2018

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!

@glasserc
Copy link
Owner

glasserc commented Mar 6, 2018

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!

@domo141
Copy link

domo141 commented Mar 6, 2018

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

@glasserc
Copy link
Owner

glasserc commented Mar 7, 2018

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 :)

@domo141
Copy link

domo141 commented May 27, 2019

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants