1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-12 09:28:11 +00:00

org-persist-register: Make return value meaningful with :write-immidiately

* lisp/org-persist.el (org-persist-register): Return the return value
of `org-persist-write' when `:write-immediately' is non-nil.
This commit is contained in:
Ihor Radchenko 2022-01-26 10:49:52 +08:00
parent caccec2c54
commit 6b175fb227
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B

View File

@ -697,7 +697,9 @@ last access, or a function accepting a single argument - collection.
EXPIRY key has no effect when INHERIT is non-nil.
Optional key WRITE-IMMEDIATELY controls whether to save the container
data immediately.
MISC will be appended to CONTAINER."
MISC will be appended to CONTAINER.
When WRITE-IMMEDIATELY is non-nil, the return value will be the same
with `org-persist-write'."
(unless org-persist--index (org-persist--load-index))
(setq container (org-persist--normalize-container container))
(when inherit
@ -713,12 +715,12 @@ MISC will be appended to CONTAINER."
(let ((collection (org-persist--get-collection container associated misc)))
(when (and expiry (not inherit))
(when expiry (plist-put collection :expiry expiry))))
(when write-immediately (org-persist-write container associated))
(when (or (bufferp associated) (bufferp (plist-get associated :buffer)))
(with-current-buffer (if (bufferp associated)
associated
(plist-get associated :buffer))
(add-hook 'kill-buffer-hook #'org-persist-write-all-buffer nil 'local))))
(add-hook 'kill-buffer-hook #'org-persist-write-all-buffer nil 'local)))
(when write-immediately (org-persist-write container associated)))
(defun org-persist-unregister (container &optional associated)
"Unregister CONTAINER in ASSOCIATED to be persistent.