[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 2e5db7a591 2/4: org-element-cache: Catch problems w
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 2e5db7a591 2/4: org-element-cache: Catch problems with persistent cache and abort loading |
Date: |
Sat, 16 Sep 2023 06:58:45 -0400 (EDT) |
branch: externals/org
commit 2e5db7a5919bd420818e1ab64fabc004062f13db
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
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.
---
lisp/org-element.el | 39 +++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 37c2d201f3..162aeda289 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -7389,22 +7389,29 @@ 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)))
(with-current-buffer (get-file-buffer (plist-get associated :file))
(when (and org-element-use-cache org-element-cache-persistent)
- (when (and (equal container '(elisp org-element--cache))
org-element--cache)
- ;; Restore `:buffer' property.
- (avl-tree-mapc
- (lambda (el)
- (org-element-map el t
- (lambda (el2)
- (unless (org-element-type-p el2 'plain-text)
- (org-element-put-property el2 :buffer (current-buffer))))
- nil nil nil 'with-affiliated 'no-undefer)
- (org-element--cache-log-message
- "Recovering persistent cached element: %S"
- (org-element--format-element el)))
- 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)
- (setq-local org-element--headline-cache-size (avl-tree-size
org-element--headline-cache)))))))
+ (catch 'abort
+ (when (and (equal container '(elisp org-element--cache))
org-element--cache)
+ ;; Restore `:buffer' property.
+ (avl-tree-mapc
+ (lambda (el)
+ (org-element-map el t
+ (lambda (el2)
+ (unless (org-element-type-p el2 'plain-text)
+ (org-element-put-property el2 :buffer (current-buffer))))
+ nil nil nil 'with-affiliated 'no-undefer)
+ (org-element--cache-log-message
+ "Recovering persistent cached element: %S"
+ (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)
+ (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)
+ (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-read-hook
#'org-element--cache-persist-before-read)