forked from mirrors/org-mode
org-element-cache: Catch problems with persistent cache and abort loading
* lisp/org-element.el (org-element--cache-persist-after-read): When the persistent cache has elements without parent, do not use such cache and report a warning to user.
This commit is contained in:
parent
aee3f2227f
commit
2e5db7a591
|
@ -7389,6 +7389,7 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S"
|
||||||
(get-file-buffer (plist-get associated :file)))
|
(get-file-buffer (plist-get associated :file)))
|
||||||
(with-current-buffer (get-file-buffer (plist-get associated :file))
|
(with-current-buffer (get-file-buffer (plist-get associated :file))
|
||||||
(when (and org-element-use-cache org-element-cache-persistent)
|
(when (and org-element-use-cache org-element-cache-persistent)
|
||||||
|
(catch 'abort
|
||||||
(when (and (equal container '(elisp org-element--cache)) org-element--cache)
|
(when (and (equal container '(elisp org-element--cache)) org-element--cache)
|
||||||
;; Restore `:buffer' property.
|
;; Restore `:buffer' property.
|
||||||
(avl-tree-mapc
|
(avl-tree-mapc
|
||||||
|
@ -7400,11 +7401,17 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S"
|
||||||
nil nil nil 'with-affiliated 'no-undefer)
|
nil nil nil 'with-affiliated 'no-undefer)
|
||||||
(org-element--cache-log-message
|
(org-element--cache-log-message
|
||||||
"Recovering persistent cached element: %S"
|
"Recovering persistent cached element: %S"
|
||||||
(org-element--format-element el)))
|
(org-element--format-element el))
|
||||||
|
(when (and (not (org-element-parent el)) (not (org-element-type-p el 'org-data)))
|
||||||
|
(org-element--cache-warn
|
||||||
|
"Got element without parent when loading cache from disk. Not using this persistent cache.
|
||||||
|
Please report it to Org mode mailing list (M-x org-submit-bug-report).\n%S" el)
|
||||||
|
(org-element-cache-reset)
|
||||||
|
(throw 'abort t)))
|
||||||
org-element--cache)
|
org-element--cache)
|
||||||
(setq-local org-element--cache-size (avl-tree-size org-element--cache)))
|
(setq-local org-element--cache-size (avl-tree-size org-element--cache)))
|
||||||
(when (and (equal container '(elisp org-element--headline-cache)) org-element--headline-cache)
|
(when (and (equal container '(elisp org-element--headline-cache)) org-element--headline-cache)
|
||||||
(setq-local org-element--headline-cache-size (avl-tree-size org-element--headline-cache)))))))
|
(setq-local org-element--headline-cache-size (avl-tree-size org-element--headline-cache))))))))
|
||||||
|
|
||||||
(add-hook 'org-persist-before-write-hook #'org-element--cache-persist-before-write)
|
(add-hook 'org-persist-before-write-hook #'org-element--cache-persist-before-write)
|
||||||
(add-hook 'org-persist-before-read-hook #'org-element--cache-persist-before-read)
|
(add-hook 'org-persist-before-read-hook #'org-element--cache-persist-before-read)
|
||||||
|
|
Loading…
Reference in a new issue