소스 검색

org-element--cache-sync: Handle silent changes for non-latin input methods

* lisp/org-element.el (org-element--cache-sync): Detect silent changes
in buffer made by quail.el when non-latin input methods are active.
These silent changes do not modify the buffer, but only change
`buffer-chars-modified-tick' and do no affect element cache.  Note
that the detection uses heuristics.

Fixes https://list.orgmode.org/87sfw2luhj.fsf@localhost/T/#you
Ihor Radchenko 3 년 전
부모
커밋
d8606c316e
1개의 변경된 파일15개의 추가작업 그리고 2개의 파일을 삭제
  1. 15 2
      lisp/org-element.el

+ 15 - 2
lisp/org-element.el

@@ -5835,8 +5835,21 @@ updated before current modification are actually submitted."
     (with-current-buffer (or (buffer-base-buffer buffer) buffer)
       ;; Check if the buffer have been changed outside visibility of
       ;; `org-element--cache-before-change' and `org-element--cache-after-change'.
-      (if (/= org-element--cache-change-tic
-             (buffer-chars-modified-tick))
+      (if (and (/= org-element--cache-change-tic
+                  (buffer-chars-modified-tick))
+               ;; FIXME: Below is a heuristics noticed by observation.
+               ;; quail.el with non-latin input does silent
+               ;; modifications in buffer increasing the tick counter
+               ;; but not actually changing the buffer text:
+               ;; https://list.orgmode.org/87sfw2luhj.fsf@localhost/T/#you
+               ;; https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-11/msg00894.html
+               ;; However, the values of `buffer-chars-modified-tick'
+               ;; and `buffer-modified-tick' appear to be same after
+               ;; the quail.el's changes in buffer.  We do not
+               ;; consider these exact changes as a dangerous silent
+               ;; edit.
+               (/= (buffer-chars-modified-tick)
+                  (buffer-modified-tick)))
           (progn
             (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).