Browse Source

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
Ihor Radchenko 4 years ago
parent
commit
1492fc5857
1 changed files with 3 additions and 1 deletions
  1. 3 1
      lisp/org-element.el

+ 3 - 1
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
   (when (and org-element-use-cache
              buffer
              buffer
              org-element-cache-persistent
              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
     (with-current-buffer buffer
       ;; Cleanup cache request keys to avoid collisions during next
       ;; Cleanup cache request keys to avoid collisions during next
       ;; Emacs session.
       ;; Emacs session.