From 1492fc585771955931649ddb307f2660125468e7 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 5 Nov 2021 22:21:33 +0800 Subject: [PATCH] org-element--cache-persist-before-write: Avoid saving in non-org buffers * lisp/org-element.el (org-element--cache-persist-before-write): Do not try to save cache when buffer is not in Org mode and when cache is not initialised. Fixes https://list.orgmode.org/CAFyQvY1rEbL8LJWSR-q6sNgwS1_+Assyd=Jmv1YgeeQ_R3Yn5g@mail.gmail.com/T/#u --- lisp/org-element.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 9e917c31f..346f47b5d 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -6874,7 +6874,9 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S" (when (and org-element-use-cache buffer org-element-cache-persistent - (eq var 'org-element--cache)) + (eq var 'org-element--cache) + (derived-mode-p 'org-mode) + org-element--cache) (with-current-buffer buffer ;; Cleanup cache request keys to avoid collisions during next ;; Emacs session.