lewang / ws-butler

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

Don't propertize minibuffer input #35

Open Ambrevar opened 3 years ago

Ambrevar commented 3 years ago

When I enable ws-butler, minibuffer gets propertized.

For instance, the helm-pattern variable in all Helm candidate functions looks like

#("foo" 0 2 (ws-butler-chg chg))

instead of

"foo"

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?

bram85 commented 1 year 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)
Ambrevar commented 1 year ago

Seems like a good fix indeed!

bram85 commented 1 year ago

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/

Ambrevar commented 1 year ago

Thanks!

phil-s commented 1 year ago

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.

bram85 commented 1 year ago

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

phil-s commented 1 year ago

Add special-mode to ws-butler-global-exempt-modes?

bram85 commented 1 year ago

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