0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 18:36:26 +00:00

org-persist-write-all: Speed up writing

* lisp/org-persist.el (org-persist-write): New optional argument
bypassing extra `org-persist-read' invocation.
(org-persist-write-all): Call faster version of `org-persist-write'.
This commit is contained in:
Ihor Radchenko 2022-01-26 19:24:39 +08:00
parent f0e0716f54
commit 19a383d9f4
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -800,13 +800,15 @@ The arguments have the same meaning as in `org-persist-read'."
"Call `org-persist-load-all' in current buffer."
(org-persist-load-all (current-buffer)))
(defun org-persist-write (container &optional associated)
(defun org-persist-write (container &optional associated ignore-return)
"Save CONTAINER according to ASSOCIATED.
ASSOCIATED can be a plist, a buffer, or a string.
A buffer is treated as (:buffer ASSOCIATED).
A string is treated as (:file ASSOCIATED).
The return value is nil when writing fails and the written value (as
returned by `org-persist-read') on success."
returned by `org-persist-read') on success.
When IGNORE-RETURN is non-nil, just return t on success without calling
`org-persist-read'."
(setq associated (org-persist--normalize-associated associated))
;; Update hash
(when (and (plist-get associated :file)
@ -823,7 +825,7 @@ returned by `org-persist-read') on success."
(data (mapcar (lambda (c) (cons c (org-persist-write:generic c collection)))
(plist-get collection :container))))
(org-persist--write-elisp-file file data)
(org-persist-read container associated))))))
(or ignore-return (org-persist-read container associated)))))))
(defun org-persist-write-all (&optional associated)
"Save all the persistent data.
@ -835,10 +837,10 @@ When ASSOCIATED is non-nil, only save the matching data."
(if associated
(when collection
(cl-pushnew (plist-get collection :container) all-containers :test #'equal))
(org-persist-write (plist-get collection :container) (plist-get collection :associated))))
(org-persist-write (plist-get collection :container) (plist-get collection :associated) t)))
(dolist (container all-containers)
(when (org-persist--find-index `(:container ,container :associated ,associated))
(org-persist-write container associated)))))
(org-persist-write container associated t)))))
(defun org-persist-write-all-buffer ()
"Call `org-persist-write-all' in current buffer.