lewang / ws-butler

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

Don't propertize minibuffer input #35

Closed Ambrevar closed 1 week ago

Ambrevar commented 4 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 2 years 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 2 years ago

Seems like a good fix indeed!

bram85 commented 2 years 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 2 years ago

Thanks!

phil-s commented 2 years 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 2 years 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 2 years ago

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

bram85 commented 2 years 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))
lewang commented 1 week ago

added modes in https://github.com/lewang/ws-butler/commit/ac9f5a5f906c12d4cca1bec93f09059c44374e79