lewang / ws-butler

Unobtrusively trim extraneous white-space *ONLY* in lines edited.
242 stars 26 forks source link

Please don't look at indent-tabs-mode #25

Closed fniessen closed 7 years ago

fniessen commented 7 years ago

First of all, thanks for this definitely needed package!

Now, I'll try to explain my request:

Could you either never look at indent-tabs-mode, or add a variable to customize that?

Thanks a lot!

Deewiant commented 7 years ago

I used to work around this by overriding ws-butler-clean-region with one where I locally set indent-tabs-mode to t to prevent it from touching indentation, but after #17 this instead causes spaces to be replaced with tabs, so that's unfortunately no longer an option.

fniessen commented 7 years ago

Thanks for the follow-up. Hopefully, this will be fixed appropriately, at some point.

Right now, I've been forced to disable ws-butler, but I miss it a lot.

lewang commented 7 years ago

Would adding a ws-butler-fix-indentation customization be enough?

Are there cases where you do want to fix indentation but want to be able to override indent-tabs-mode with something ws-butler specific?

fniessen commented 7 years ago

I think this would be enough, yes, if it allows me to insert tabs (to follow the local conventions) and does not remove them.

Thanks in advance!

ambihelical commented 7 years ago

This behaviour also interferes with smart-tabs-mode (where indent-tabs-mode must be t). ws-butler dutifully replaces all of the non-indentation spaces smart-tabs-mode has inserted with tabs. So the option to disable it would make this case work correctly, I think.

ian-kelling commented 7 years ago

Don't have the time right now to make this conditional, add an option and a pull request. Until someone does, they can add this to their init file to remove all tab/space indent conversion.

(defun ws-butler-clean-region (beg end)
  "Delete trailing blanks in region BEG END."
  (interactive "*r")
  (ws-butler-with-save
   (narrow-to-region beg end)
   ;;  _much slower would be:       (replace-regexp "[ \t]+$" "")
   (goto-char (point-min))
   (while (not (eobp))
     (end-of-line)
     (delete-horizontal-space)
     (forward-line 1)))
  ;; clean return code for hooks
  nil)
fniessen commented 7 years ago

@ian-kelling This works perfectly. Thanks!

arybczak commented 7 years ago

Thanks for this. I would personally consider not touching indentation as a sane default, as doing a covert conversion seems to conflict with the theme of the package (an unobtrusive way to trim spaces from end of line).

npostavs commented 7 years ago

Why not just add a .dir-locals.el file which sets indent-tabs-mode appropriately?

ambihelical commented 7 years ago

@npostavs This wouldn't work with smart-tabs-mode at all. Ws-butler is currently completely incompatible with it. It used to work well.

ian-kelling commented 7 years ago

This issue is fixed by my pull request #28. You can also fix it using my comment above in the meantime.