Function: org-persist--add-to-index

org-persist--add-to-index is a byte-compiled function defined in org-persist.el.gz.

Signature

(org-persist--add-to-index COLLECTION &optional HASH-ONLY)

Documentation

Add or update COLLECTION in org-persist--index.

When optional HASH-ONLY is non-nil, only modify the hash table. Return PLIST.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-persist.el.gz
(defun org-persist--add-to-index (collection &optional hash-only)
  "Add or update COLLECTION in `org-persist--index'.
When optional HASH-ONLY is non-nil, only modify the hash table.
Return PLIST."
  (org-persist-collection-let collection
    (let ((existing (org-persist--find-index collection)))
      (if existing
          (progn
            (plist-put existing :container container)
            (plist-put (plist-get existing :associated) :file path)
            (plist-put (plist-get existing :associated) :inode inode)
            (plist-put (plist-get existing :associated) :hash hash)
            (plist-put (plist-get existing :associated) :key key)
            existing)
        (unless hash-only (push collection org-persist--index))
        (unless org-persist--index-hash (setq org-persist--index-hash (make-hash-table :test 'equal)))
        (dolist (cont (cons container container))
          (puthash (cons cont associated) collection org-persist--index-hash)
          (when path (puthash (cons cont (list :file path)) collection org-persist--index-hash))
          (when inode (puthash (cons cont (list :inode inode)) collection org-persist--index-hash))
          (when hash (puthash (cons cont (list :hash inode)) collection org-persist--index-hash))
          (when key (puthash (cons cont (list :key inode)) collection org-persist--index-hash)))
        collection))))