You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GNU Emacs v27.2
Doom core v3.0.0-dev
Doom modules v22.08.0-dev grafted, HEAD -> master, origin/master, origin/HEAD c44bc81 2022-08-19 11:24:34 0200
Org mode version 9.6 (9.6-??-00adad9)
problem
ws-butler-keep-whitespace-before-point set to t
org-element-use-cache is set to t
saving an orgmode buffer, with trailing spaces before the point
warning pops up:
Warning (org-element-cache): org-element--cache: Unregistered buffer modifications detected. Resetting.
If this warning appears regularly, please report the warning text to Org mode mailing list (M-x org-submit-bug-report).
The buffer is: xyz.org
Current command: nil
Backtrace:
" backtrace-to-string(nil)
org-element--cache-sync(#<buffer xyz.org>)
apply(org-element--cache-sync #<buffer xyz.org>)
timer-event-handler([t 0 5 323697 nil org-element--cache-sync (#<buffer xyz.org>) idle 850999])
"
notes
i think it is because ws-butler-after-save modifies the buffer while inhibiting org-element change-hook functions to run (org-element--cache-before-change and/or org-element--cache-after-change)
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
)The text was updated successfully, but these errors were encountered: