org-element--cache-sync: Another take on false positive warnings

* lisp/org-element.el (org-element--cache-sync): Suppress silent edit
warnings for Emacs <28.  In older Emacs, Emacs internal functions can
modify `buffer-chars-modified-tick' and cannot be distinguished from
dangerous edits under `inhibit-modification-hooks'.  Some of the
functions even have the same footprint with the edits we want to
avoid.
This commit is contained in:
Ihor Radchenko 2021-12-04 12:52:16 +08:00
parent 8ca254696b
commit 9843670d11
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -5868,19 +5868,15 @@ updated before current modification are actually submitted."
(buffer-modified-tick))) (buffer-modified-tick)))
(progn (progn
(when (or (and org-element--cache-diagnostics-modifications (when (or (and org-element--cache-diagnostics-modifications
;; FIXME: Some more special cases when ;; A number of Emacs internal operations in
;; non-latin input in Emacs <28 triggers ;; Emacs 26 and 27 alter
;; changes in `buffer-chars-modified-tick' ;; `buffer-chars-modified-tick' (see
;; even though the buffer text remains ;; https://list.orgmode.org/87ee7jdv70.fsf@localhost/T/#t).
;; unchanged. We still reset the cache as ;; We have no way to distinguish them from
;; safety precaution, but do not show the ;; dangerious silent edits. So, we can
;; warning. ;; only reset the cache, but do not show
(not (memq (- (buffer-modified-tick) ;; warning to not irritate the users.)
(buffer-chars-modified-tick)) (not (version< emacs-version "28")))
;; Note: 4 is a footprint for
;; (let ((inhibit-modification-hooks t))
;; (insert "blah"))
'(1 3 6 7 8 9))))
(and (boundp 'org-batch-test) org-batch-test)) (and (boundp 'org-batch-test) org-batch-test))
(org-element--cache-warn "Unregistered buffer modifications detected. Resetting. (org-element--cache-warn "Unregistered buffer modifications detected. Resetting.
If this warning appears regularly, please report it to Org mode mailing list (M-x org-submit-bug-report). If this warning appears regularly, please report it to Org mode mailing list (M-x org-submit-bug-report).