org-persist-read: Attempt to write newly register data before reading

* lisp/org-persist.el (org-persist-read): If data is not yet written,
try to write it before reading.
This commit is contained in:
Ihor Radchenko 2022-12-28 09:21:13 +03:00
parent 5549357bf2
commit e8cb52bd3e
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 6 additions and 2 deletions

View File

@ -828,14 +828,18 @@ When LOAD? is non-nil, load the data instead of reading."
(plist-get collection :persist-file))))
(data nil))
(when (and collection
(file-exists-p persist-file)
(or (not (plist-get collection :expiry)) ; current session
(not (org-persist--gc-expired-p
(plist-get collection :expiry) collection)))
(or (not hash-must-match)
(and (plist-get associated :hash)
(equal (plist-get associated :hash)
(plist-get (plist-get collection :associated) :hash)))))
(plist-get (plist-get collection :associated) :hash))))
(or (file-exists-p persist-file)
;; Attempt to write data if it is not yet written.
(progn
(org-persist-write container associated 'no-read)
(file-exists-p persist-file))))
(unless (seq-find (lambda (v)
(run-hook-with-args-until-success 'org-persist-before-read-hook v associated))
(plist-get collection :container))