org-element--cache-persist-before-write: Warn when writing incorrect cache

* lisp/org-element.el (org-element--cache-persist-before-write): When
the cache being written has elements without parent, warn the user.
This commit is contained in:
Ihor Radchenko 2023-09-20 14:22:31 +03:00
parent 8b18fc5817
commit 266aac1186
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -7359,7 +7359,10 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S"
(lambda (el2)
(unless (org-element-type-p el2 'plain-text)
(org-element-put-property el2 :buffer nil)))
nil nil nil 'with-affiliated 'no-undefer))
nil nil nil 'with-affiliated 'no-undefer)
(when (and (not (org-element-parent el)) (not (org-element-type-p el 'org-data)))
(org-element--cache-warn
"Got element without parent when writing cache to disk.\n%S" el)))
org-element--cache)
nil)
'forbid))