Function: org-element--cache-active-p

org-element--cache-active-p is a byte-compiled function defined in org-element.el.gz.

Signature

(org-element--cache-active-p &optional CALLED-FROM-CACHE-CHANGE-FUNC-P)

Documentation

Non-nil when cache is active in current buffer.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
;;;; Tools

;; FIXME: Ideally, this should be inlined to avoid overheads, but
;; inlined functions should be declared before the code that uses them
;; and some code above does use `org-element--cache-active-p'.  Moving this
;; declaration on top would require restructuring the whole cache
;; section.
(defun org-element--cache-active-p (&optional called-from-cache-change-func-p)
  "Non-nil when cache is active in current buffer."
  (org-with-base-buffer nil
    (and org-element-use-cache
         org-element--cache
         (or called-from-cache-change-func-p
             (eq org-element--cache-change-tic (buffer-chars-modified-tick))
             (and
              ;; org-num-mode calls some Org structure analysis functions
              ;; that can trigger cache update in the middle of changes.  See
              ;; `org-num--verify' calling `org-num--skip-value' calling
              ;; `org-entry-get' that uses cache.
              ;; Forcefully disable cache when called from inside a
              ;; modification hook, where `inhibit-modification-hooks' is set
              ;; to t.
              (not inhibit-modification-hooks)
              ;; `combine-change-calls' sets `after-change-functions' to
              ;; nil.  We need not to use cache inside
              ;; `combine-change-calls' because the buffer is potentially
              ;; changed without notice (the change will be registered
              ;; after exiting the `combine-change-calls' body though).
              (catch :inhibited
                (org-fold-core-cycle-over-indirect-buffers
                  (unless (memq #'org-element--cache-after-change after-change-functions)
                    (throw :inhibited nil)))
                t))))))