Open bitclick opened 1 year ago
dooms modules add an advice to ws-butler-after-save
(modules/ui/modeline/config.el
):
;; Some functions modify the buffer, causing the modeline to show a false
;; modified state, so force them to behave.
(defadvice! +modeline--inhibit-modification-hooks-a (fn &rest args)
:around #'ws-butler-after-save
(with-silent-modifications (apply fn args)))
but this seems not to be the cause (i tested it without the advice), problem still occurs
I know it's a bit late but I created a ws-butler-trim-predicate
function that helps me partially avoid this issue.
(after! ws-butler
(setq ws-butler-trim-predicate
(lambda (beg end)
(let* ((current-line (line-number-at-pos))
(beg-line (line-number-at-pos beg))
(end-line (line-number-at-pos end))
;; Assuming the use of evil-mode for insert mode detection. Adjust if using a different system.
(in-insert-mode (and (bound-and-true-p evil-mode)
(eq 'insert evil-state))))
;; Return true (allow trimming) unless in insert mode and the current line is within the region.
(not (and in-insert-mode
(>= current-line beg-line)
(<= current-line end-line))))))
)
Simply avoid trimming a region if it contains the $current_line I am in insert-mode with. I currently use auto-save @ the default interval so it'll eventually clean up any trailing whitespace.
For my use this expectation only fails when I switch buffers quickly (auto-save won't trigger anymore) but that is unrelated to ws-butler
. I hope it helps @bitclick
affected version:
problem
ws-butler-keep-whitespace-before-point
set tot
org-element-use-cache
is set tot
notes
ws-butler-after-save
modifies the buffer while inhibiting org-element change-hook functions to run (org-element--cache-before-change
and/ororg-element--cache-after-change
)