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
This commit is contained in:
Ihor Radchenko 2021-11-05 22:21:33 +08:00
parent ced2b33357
commit 1492fc5857
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 3 additions and 1 deletions

View File

@ -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.