lewang / ws-butler

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

white space before point trimmed in non focused buffer #46

Open gusbrs opened 1 year ago

gusbrs commented 1 year ago

When a buffer with ws-butler-mode enabled is saved, but is not in focus (not current buffer), ws-butler-keep-whitespace-before-point is not honored, and "virtual spaces" in front of point are not preserved.

To reproduce, start with emacs -Q, then setup:

(add-to-list 'load-path "~/.emacs.d/elpa/ws-butler-0.6/")
(require 'ws-butler)
(ws-butler-global-mode)

Visit a file visiting buffer, say "test1.txt", and type "word " (that is, "word" and a space) and leave point there. Visit a second file, say "test2.txt", and from there run save-some-buffers ("C-x s"). Emacs asks for confirmation to save "text1.txt", say "y". Switch back to "text1.txt" and see that the space after "word" and before point is gone.

A slight variation where you can actually see this happening is to do the same, but from a different window. Thus. Visit "test1.txt", split the window in two with "C-x 2", switch to "text2.txt", run save-some-buffers ("C-x s"), confirm.

Example tested on GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2022-09-12 with ws-butler-0.6.