cache-dir))
"org-persist/"))
"Directory where the data is stored."
- :group 'org-persist
:package-version '(Org . "9.6")
:type 'directory)
Note that the last option `check-existence' may cause Emacs to show
password prompts to log in."
- :group 'org-persist
:package-version '(Org . "9.6")
:type '(choice (const :tag "Never" nil)
(const :tag "Always" t)
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
:package-version '(Org . "9.6")
:type '(choice (const :tag "Never" never)
(const :tag "Always" nil)
;;;; Working with index
(defmacro org-persist-collection-let (collection &rest body)
- "Bind container and associated from COLLECTION and execute BODY."
+ "Bind container and associated from COLLECTION and execute BODY.
+BODY is executed in a context with the following additional variables:
+`container', `associated', `path', `inode', `hash', and `key'."
(declare (debug (form body)) (indent 1))
- `(with-no-warnings
- (let* ((container (plist-get ,collection :container))
- (associated (plist-get ,collection :associated))
- (path (plist-get associated :file))
- (inode (plist-get associated :inode))
- (hash (plist-get associated :hash))
- (key (plist-get associated :key)))
- ;; Suppress "unused variable" warnings.
- (ignore container associated path inode hash key)
- ,@body)))
+ `(let* ((container (plist-get ,collection :container))
+ (associated (plist-get ,collection :associated))
+ (path (plist-get associated :file))
+ (inode (plist-get associated :inode))
+ (hash (plist-get associated :hash))
+ (key (plist-get associated :key)))
+ ;; Suppress "unused variable" warnings.
+ (ignore container associated path inode hash key)
+ ,@body))
(defun org-persist--find-index (collection)
-"Find COLLECTION in `org-persist--index'."
-(org-persist-collection-let collection
- (and org-persist--index-hash
- (catch :found
- (dolist (cont (cons container container))
- (let (r)
- (setq r (or (gethash (cons cont associated) org-persist--index-hash)
- (and path (gethash (cons cont (list :file path)) org-persist--index-hash))
- (and inode (gethash (cons cont (list :inode inode)) org-persist--index-hash))
- (and hash (gethash (cons cont (list :hash hash)) org-persist--index-hash))
- (and key (gethash (cons cont (list :key key)) org-persist--index-hash))))
- (when r (throw :found r))))))))
+ "Find COLLECTION in `org-persist--index'."
+ (org-persist-collection-let collection
+ (and org-persist--index-hash
+ (catch :found
+ (dolist (cont (cons container container))
+ (let ((r (or (gethash (cons cont associated) org-persist--index-hash)
+ (and path (gethash (cons cont (list :file path)) org-persist--index-hash))
+ (and inode (gethash (cons cont (list :inode inode)) org-persist--index-hash))
+ (and hash (gethash (cons cont (list :hash hash)) org-persist--index-hash))
+ (and key (gethash (cons cont (list :key key)) org-persist--index-hash)))))
+ (when r (throw :found r))))))))
(defun org-persist--add-to-index (collection &optional hash-only)
"Add or update COLLECTION in `org-persist--index'.
(when key (puthash (cons cont (list :key inode)) collection org-persist--index-hash)))
collection))))
+(defmacro org-persist-associated-files:generic (container collection)
+ "List associated files in `org-persist-directory' of CONTAINER in COLLECTION."
+ `(let* ((c (org-persist--normalize-container ,container))
+ (assocf-func-symbol (intern (format "org-persist-associated-files:%s" (car c)))))
+ (if (fboundp assocf-func-symbol)
+ (funcall assocf-func-symbol c ,collection)
+ (error "org-persist: Read function %s not defined"
+ assocf-func-symbol))))
+
(defun org-persist--remove-from-index (collection)
"Remove COLLECTION from `org-persist--index'."
(let ((existing (org-persist--find-index collection)))
(when (org-directory-empty-p (file-name-directory persist-file))
(delete-directory (file-name-directory persist-file)))))
-(defmacro org-persist-associated-files:generic (container collection)
- "List associated files in `org-persist-directory' of CONTAINER in COLLECTION."
- `(let* ((c (org-persist--normalize-container ,container))
- (assocf-func-symbol (intern (format "org-persist-associated-files:%s" (car c)))))
- (if (fboundp assocf-func-symbol)
- (funcall assocf-func-symbol c ,collection)
- (error "org-persist: Read function %s not defined"
- assocf-func-symbol))))
-
(defalias 'org-persist-associated-files:elisp #'ignore)
(defalias 'org-persist-associated-files:index #'ignore)
(defalias 'org-persist-associated-files:elisp-data #'ignore)