Function: org-persist-write-all

org-persist-write-all is a byte-compiled function defined in org-persist.el.gz.

Signature

(org-persist-write-all &optional ASSOCIATED)

Documentation

Save all the persistent data.

When ASSOCIATED is non-nil, only save the matching data.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-persist.el.gz
(defun org-persist-write-all (&optional associated)
  "Save all the persistent data.
When ASSOCIATED is non-nil, only save the matching data."
  (unless org-persist--index (org-persist--load-index))
  (setq associated (org-persist--normalize-associated associated))
  (if
      (and (equal 1 (length org-persist--index))
           ;; The single collection only contains a single container
           ;; in the container list.
           (equal 1 (length (plist-get (car org-persist--index) :container)))
           ;; The container is an `index' container.
           (eq 'index (caar (plist-get (car org-persist--index) :container)))
           (or (not (file-exists-p org-persist-directory))
               (org-directory-empty-p org-persist-directory)))
      ;; Do not write anything, and clear up `org-persist-directory' to reduce
      ;; clutter.
      (when (and (file-exists-p org-persist-directory)
                 (org-directory-empty-p org-persist-directory))
        (delete-directory org-persist-directory))
    ;; Write the data.
    (let (all-containers)
      (dolist (collection org-persist--index)
        (if associated
            (when collection
              (cl-pushnew (plist-get collection :container) all-containers :test #'equal))
          (condition-case err
              (org-persist-write (plist-get collection :container) (plist-get collection :associated) t)
            (error
             (message "%s. Deleting bad index entry." err)
             (org-persist--remove-from-index collection)
             nil))))
      (dolist (container all-containers)
        (let ((collection (org-persist--find-index `(:container ,container :associated ,associated))))
          (when collection
            (condition-case err
                (org-persist-write container associated t)
              (error
               (message "%s. Deleting bad index entry." err)
               (org-persist--remove-from-index collection)
               nil))))))))