Closed Ambrevar closed 1 week ago
Wouldn't it be better to check if the buffer is backed by a file or not?
(define-globalized-minor-mode ws-butler-global-mode ws-butler-mode
(lambda ()
(unless (or (apply #'derived-mode-p ws-butler-global-exempt-modes)
- (minibufferp))
+ (not (buffer-file-name)))
(ws-butler-mode))))
(provide 'ws-butler)
Seems like a good fix indeed!
I made a new pull request to make this fix.
https://github.com/lewang/ws-butler/pull/45
Or you can fetch the fix from my clone https://github.com/bram85/ws-butler/
Thanks!
Wouldn't it be better to check if the buffer is backed by a file or not?
Is that solving any additional problem?
I realise that ws-butler only trims whitespace upon saving, but you can have non-file-visiting buffers which are then written to a file.
The main reason was to exclude special buffers, for instance Magit buffers. I noticed that Magit spawns git processes with propertized arguments instead of plain text, because ws-butler treated the buffer parts that Magit uses for further processing.
When compiling a list of modes to exclude, I noticed all of them are special buffers, not backed by a file.
I'm aware of your use case, but for me personally it's relatively rare to C-x C-w something, so for me the fix is sufficient.
Another alternative is perhaps (or (minibufferp) buffer-read-only)
instead of (not (buffer-file-name))
Add special-mode
to ws-butler-global-exempt-modes
?
Indeed, I had the impression that Magit didn't inherit from special-mode but it turns out it does. So I settled with (and no code changes).
(setq ws-butler-global-exempt-modes '(minibuffer-mode special-mode))
When I enable ws-butler, minibuffer gets propertized.
For instance, the
helm-pattern
variable in all Helm candidate functions looks likeinstead of
This breaks numerous Helm packages, including Helm SLY (https://github.com/joaotavora/sly/issues/370), but not only that, other modes suffer from this issue:
https://github.com/hrs/engine-mode/issues/43
Any way to fix this?