Function: org-element--cache-remove

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

Signature

(org-element--cache-remove ELEMENT)

Documentation

Remove ELEMENT from cache.

Assume ELEMENT belongs to cache and that a cache is active.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
(defsubst org-element--cache-remove (element)
  "Remove ELEMENT from cache.
Assume ELEMENT belongs to cache and that a cache is active."
  (org-with-base-buffer nil
    (org-element-put-property element :cached nil)
    (cl-decf org-element--cache-size)
    ;; Invalidate contents of parent.
    (when (org-element-contents
           ;; Cached elements cannot have deferred `:parent'.
           (org-element-property-raw :parent element))
      (org-element-set-contents
       (org-element-property-raw :parent element) nil))
    (when (org-element-type-p element '(headline inlinetask))
      (cl-decf org-element--headline-cache-size)
      (avl-tree-delete org-element--headline-cache element))
    (org-element--cache-log-message
     "Decreasing cache size to %S"
     org-element--cache-size)
    (when (< org-element--cache-size 0)
      (org-element--cache-warn
       "Cache grew to negative size in %S when deleting %S at %S.  Cache key: %S.
If this warning appears regularly, please report the warning text to Org mode mailing list (M-x org-submit-bug-report)."
       (org-element-type element)
       (current-buffer)
       (org-element-begin element)
       (org-element-property :org-element--cache-sync-key element))
      (org-element-cache-reset)
      (throw 'org-element--cache-quit nil))
    (or (avl-tree-delete org-element--cache element)
        (progn
          ;; This should not happen, but if it is, would be better to know
          ;; where it happens.
          (org-element--cache-warn
           "Failed to delete %S element in %S at %S. The element cache key was %S.
If this warning appears regularly, please report the warning text to Org mode mailing list (M-x org-submit-bug-report)."
           (org-element-type element)
           (current-buffer)
           (org-element-begin element)
           (org-element-property :org-element--cache-sync-key element))
          (org-element-cache-reset)
          (throw 'org-element--cache-quit nil)))))