org-element-cache: Make sure that cache is correctly synced before saving

* lisp/org-element.el (org-element--cache-persist-before-write): Sync
cache before force-overwriting transient cache keys.
This commit is contained in:
Ihor Radchenko 2022-06-29 09:16:01 +08:00
parent eb796ae432
commit aa5bc2c760
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 9 additions and 10 deletions

View File

@ -7166,16 +7166,15 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S"
(with-current-buffer (get-file-buffer (plist-get associated :file))
(if (and (derived-mode-p 'org-mode)
org-element--cache)
(progn
;; Cleanup cache request keys to avoid collisions during next
;; Emacs session.
(avl-tree-mapc
(lambda (el)
(org-element-put-property el :org-element--cache-sync-key nil))
org-element--cache)
(org-with-wide-buffer
(org-element-at-point (point-max)))
nil)
(org-with-wide-buffer
(org-element--cache-sync (current-buffer) (point-max))
;; Cleanup cache request keys to avoid collisions during next
;; Emacs session.
(avl-tree-mapc
(lambda (el)
(org-element-put-property el :org-element--cache-sync-key nil))
org-element--cache)
nil)
'forbid))
'forbid)))