0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 18:36:26 +00:00

org-element.el: Handle cache requests inside `combine-change-calls'

* lisp/org-element.el (org-element--cache-active-p): Prevent cache
queries when `org-element--cache-after-change' is not in
`after-change-functions'.  `after-change-functions' can be temporalily
set to nil by i.e. `combine-change-calls'.  We should not try to get
information from cache in such scenarios because cache may not yet be
up-to-date.  The modifications will only be registered upon exiting
the `combine-change-calls' macro.

Fixes https://list.orgmode.org/875ytggcuk.fsf@yandex.com/T/#t
This commit is contained in:
Ihor Radchenko 2021-10-29 22:23:18 +08:00
parent 1b2d06880f
commit 9f87b1cc33
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -5600,15 +5600,22 @@ This function assumes `org-element--headline-cache' is a valid AVL tree."
(and org-element-use-cache
org-element--cache
(derived-mode-p 'org-mode)
;; org-num-mode calls some Org structure analysis functions
;; that can trigger cache update in the middle of changes. See
;; `org-num--verify' calling `org-num--skip-value' calling
;; `org-entry-get' that uses cache.
;; Forcefully disable cache when called from inside a
;; modification hook, where `inhibit-modification-hooks' is set
;; to t.
(or called-from-cache-change-func-p
(not inhibit-modification-hooks)
(and
;; org-num-mode calls some Org structure analysis functions
;; that can trigger cache update in the middle of changes. See
;; `org-num--verify' calling `org-num--skip-value' calling
;; `org-entry-get' that uses cache.
;; Forcefully disable cache when called from inside a
;; modification hook, where `inhibit-modification-hooks' is set
;; to t.
(not inhibit-modification-hooks)
;; `combine-change-calls' sets `after-change-functions' to
;; nil. We need not to use cache inside
;; `combine-change-calls' because the buffer is potentially
;; changed without notice (the change will be registered
;; after exiting the `combine-change-calls' body though).
(memq #'org-element--cache-after-change after-change-functions))
(eq org-element--cache-change-tic (buffer-chars-modified-tick)))))
(defun org-element--cache-find (pos &optional side)