From 6b175fb2277b17167e2fedff6326b09fac513c7f Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Wed, 26 Jan 2022 10:49:52 +0800 Subject: [PATCH] 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. --- lisp/org-persist.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/org-persist.el b/lisp/org-persist.el index 24c4ab1e3..2c6cec4e4 100644 --- a/lisp/org-persist.el +++ b/lisp/org-persist.el @@ -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.