org-element-cache: Do not carry over warning after sync

* lisp/org-element.el (org-element--cache-sync): Set
`org-element--cache-warning' to nil at the end of synchronisation.
We do not need to consider that next request might be merged with
existing request in such scenario.
(org-element--cache-before-change): Add comment explaining the use of `org-element--cache-warning'.
This commit is contained in:
Ihor Radchenko 2021-12-16 21:09:55 +08:00
parent d267486002
commit 325b06bde4
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 12 additions and 0 deletions

View File

@ -5932,6 +5932,7 @@ The buffer is: %s\n Current command: %S\n Chars modified: %S\n Buffer modified:
;; Otherwise, reset keys.
(if org-element--cache-sync-requests
(org-element--cache-set-timer buffer)
(setq org-element--cache-change-warning nil)
(setq org-element--cache-sync-keys-value (1+ org-element--cache-sync-keys-value))))))))
(defun org-element--cache-process-request
@ -6533,6 +6534,17 @@ The function returns the new value of `org-element--cache-change-warning'."
end
(line-end-position)))))
(prog1
;; Use the worst change warning to not miss important edits.
;; This function is called before edit and after edit by
;; `org-element--cache-after-change'. Before the edit, we still
;; want to use the old value if it comes from previous
;; not yet processed edit (they may be merged by
;; `org-element--cache-submit-request'). After the edit, we want to
;; look if there was a sensitive removed during edit.
;; FIXME: This is not the most efficient way and we now
;; have to delete more elemetns than needed in some
;; cases. A better approach may be storing the warning
;; in the modification request itself.
(let ((org-element--cache-change-warning-before org-element--cache-change-warning)
(org-element--cache-change-warning-after))
(setq org-element--cache-change-warning-after