Function: org-element--cache-persist-before-read

org-element--cache-persist-before-read is a byte-compiled function defined in org-element.el.gz.

Signature

(org-element--cache-persist-before-read CONTAINER &optional ASSOCIATED)

Documentation

Avoid reading cache for CONTAINER and ASSOCIATED before Org mode is loaded.

This function is intended to be used in org-persist-before-read-hook.

Also, prevent reading cache when the buffer CONTAINER hash is not consistent with the cache.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
(defun org-element--cache-persist-before-read (container &optional associated)
  "Avoid reading cache for CONTAINER and ASSOCIATED before Org mode is loaded.
This function is intended to be used in `org-persist-before-read-hook'.

Also, prevent reading cache when the buffer CONTAINER hash is not
consistent with the cache."
  (when (equal container '(elisp org-element--cache))
    (org-element--cache-log-message "Loading persistent cache for %s" (plist-get associated :file))
    (if (not (and (plist-get associated :file)
                (get-file-buffer (plist-get associated :file))))
        (progn
          (org-element--cache-log-message "%s does not have a buffer: not loading cache" (plist-get associated :file))
          'forbid)
      (with-current-buffer (get-file-buffer (plist-get associated :file))
        (unless (and org-element-use-cache
                     org-element-cache-persistent
                     (derived-mode-p 'org-mode)
                     (equal (secure-hash 'md5 (current-buffer))
                            (plist-get associated :hash)))
          (org-element--cache-log-message "Cache is not current (or persistence is disabled) in %s" (plist-get associated :file))
          'forbid)))))