Closed fniessen closed 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.
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.
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?
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!
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.
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)
@ian-kelling This works perfectly. Thanks!
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).
Why not just add a .dir-locals.el file which sets indent-tabs-mode
appropriately?
@npostavs This wouldn't work with smart-tabs-mode at all. Ws-butler is currently completely incompatible with it. It used to work well.
This issue is fixed by my pull request #28. You can also fix it using my comment above in the meantime.
First of all, thanks for this definitely needed package!
Now, I'll try to explain my request:
Personally, I do write code without tabs at all. I do have:
;; Indentation can't insert TABs. (setq-default indent-tabs-mode nil)
in my Emacs configuration file.
C-q TAB
)... but those get removed by ws-butler at save time...Could you either never look at indent-tabs-mode, or add a variable to customize that?
Thanks a lot!