From 266aac1186256aaf3fb1bb1181ee83d548092d12 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Wed, 20 Sep 2023 14:22:31 +0300 Subject: [PATCH] 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. --- lisp/org-element.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 162aeda28..aa809e14f 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -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))