org-persist-default-expiry: Introduce and change default

* lisp/org-persist.el: New customisation controlling default persist
data expiry.  Defaults to 30 days from last access.
(org-persist-register): Change default value of `:expiry' key to
`org-persist-default-expiry'.
This commit is contained in:
Ihor Radchenko 2022-01-12 18:18:17 +08:00
parent 2a4e5a8e58
commit 7c2d93560c
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -143,6 +143,20 @@ password prompts to log in."
(number :tag "Keep not more than X files") (number :tag "Keep not more than X files")
(const :tag "Check if exist on remote" 'check-existence))) (const :tag "Check if exist on remote" 'check-existence)))
(defcustom org-persist-default-expiry 30
"Default expiry condition for persistent data.
When this variable is `nil', all the data vanishes at the end of Emacs
session. When `never', the data never vanishes. When a number, the
data is deleted that number days after last access. When a function,
it should be a function returning non-nil when the data is expired. The
function will be called with a single argument - collection."
:group 'org-persist
:type '(choice (const :tag "Never" 'never)
(const :tag "Always" nil)
(number :tag "Keep N days")
(function :tag "Function")))
(defconst org-persist-index-file "index" (defconst org-persist-index-file "index"
"File name used to store the data index.") "File name used to store the data index.")
@ -571,7 +585,7 @@ COLLECTION is the plist holding data collectin."
;;;; Public API ;;;; Public API
(cl-defun org-persist-register (container &optional associated &rest misc &key inherit &key (expiry 'never) &allow-other-keys) (cl-defun org-persist-register (container &optional associated &rest misc &key inherit &key (expiry org-persist-default-expiry) &allow-other-keys)
"Register CONTAINER in ASSOCIATED to be persistent across Emacs sessions. "Register CONTAINER in ASSOCIATED to be persistent across Emacs sessions.
Optional key INHERIT makes CONTAINER dependent on another container. Optional key INHERIT makes CONTAINER dependent on another container.
Such dependency means that data shared between variables will be Such dependency means that data shared between variables will be