[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org eca678195b 23/31: org-persist-write: Return the wri
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org eca678195b 23/31: org-persist-write: Return the written value on success |
Date: |
Sat, 29 Jan 2022 04:58:12 -0500 (EST) |
branch: externals/org
commit eca678195b8691a81f65996203ca90bba4a4dcce
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org-persist-write: Return the written value on success
---
lisp/org-persist.el | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index d4b74b52af..6ff5e7bd23 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -336,6 +336,18 @@ FORMAT and ARGS are passed to `message'."
gc-func-symbol))
(funcall gc-func-symbol c ,collection)))
+(defmacro org-persist--gc-expired-p (cnd collection)
+ "Check if expiry condition CND triggers for COLLECTION."
+ `(pcase ,cnd
+ (`nil t)
+ (`never nil)
+ ((pred numberp)
+ (when (plist-get ,collection :access-time)
+ (<= (float-time) (+ (plist-get ,collection :access-time) (* ,cnd 24 60
60)))))
+ ((pred functionp)
+ (funcall ,cnd ,collection))
+ (_ (error "org-persist: Unsupported expiry type %S" ,cnd))))
+
;;;; Working with index
(defmacro org-persist-collection-let (collection &rest body)
@@ -792,7 +804,9 @@ The arguments have the same meaning as in
`org-persist-read'."
"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)."
+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."
(setq associated (org-persist--normalize-associated associated))
;; Update hash
(when (and (plist-get associated :file)
@@ -808,7 +822,8 @@ A string is treated as (:file ASSOCIATED)."
(let ((file (org-file-name-concat org-persist-directory (plist-get
collection :persist-file)))
(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--write-elisp-file file data)
+ (org-persist-read container associated))))))
(defun org-persist-write-all (&optional associated)
"Save all the persistent data.
@@ -853,18 +868,6 @@ Do nothing in an indirect buffer."
(when (org-directory-empty-p (file-name-directory ,persist-file))
(delete-directory (file-name-directory ,persist-file)))))
-(defmacro org-persist--gc-expired-p (cnd collection)
- "Check if expiry condition CND triggers for COLLECTION."
- `(pcase ,cnd
- (`nil t)
- (`never nil)
- ((pred numberp)
- (when (plist-get ,collection :access-time)
- (<= (float-time) (+ (plist-get ,collection :access-time) (* ,cnd 24 60
60)))))
- ((pred functionp)
- (funcall ,cnd ,collection))
- (_ (error "org-persist: Unsupported expiry type %S" ,cnd))))
-
(defun org-persist-gc ()
"Remove expired or unregisted containers.
Also, remove containers associated with non-existing files."
- [elpa] externals/org 6b175fb227 27/31: org-persist-register: Make return value meaningful with :write-immidiately, (continued)
- [elpa] externals/org 6b175fb227 27/31: org-persist-register: Make return value meaningful with :write-immidiately, ELPA Syncer, 2022/01/29
- [elpa] externals/org f0e0716f54 28/31: org-element: Use new cache container format, ELPA Syncer, 2022/01/29
- [elpa] externals/org 19a383d9f4 29/31: org-persist-write-all: Speed up writing, ELPA Syncer, 2022/01/29
- [elpa] externals/org ac5742f296 31/31: Merge branch 'feature/org-persist-new-tidy', ELPA Syncer, 2022/01/29
- [elpa] externals/org 38a681fdae 05/31: org-element-cache-reset: Do not persist caches for non-file buffers, ELPA Syncer, 2022/01/29
- [elpa] externals/org 8821ff5811 09/31: org-persist-read: Do not try to read non-existing containers, ELPA Syncer, 2022/01/29
- [elpa] externals/org 4ec57a9453 16/31: org-persist: Update commentary, ELPA Syncer, 2022/01/29
- [elpa] externals/org ec787fb218 19/31: org-persist: Implement "file" and "url" containers linked to other file, ELPA Syncer, 2022/01/29
- [elpa] externals/org 6a5874bb26 25/31: org-persist-write: Overwrite existing copy if write is requested, ELPA Syncer, 2022/01/29
- [elpa] externals/org 0e18c617cf 24/31: org-persist-write:index: Return index path on write, ELPA Syncer, 2022/01/29
- [elpa] externals/org eca678195b 23/31: org-persist-write: Return the written value on success,
ELPA Syncer <=
- [elpa] externals/org 0526acd16f 22/31: org-persist-register: New optional keyword to force immidiate write, ELPA Syncer, 2022/01/29
- [elpa] externals/org caccec2c54 26/31: org-persist: Use symbols as container names, ELPA Syncer, 2022/01/29
- [elpa] externals/org 7014675226 30/31: org-mode: Fix cache loading order, ELPA Syncer, 2022/01/29
- [elpa] externals/org 1c79af13df 04/31: org-persist-gc: Fix when expiry is days and data is freshly created, ELPA Syncer, 2022/01/29