[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals-release/org aa86ed534f 1/2: org-persist-write-all: Do n
From: |
ELPA Syncer |
Subject: |
[elpa] externals-release/org aa86ed534f 1/2: org-persist-write-all: Do not create index with no containers |
Date: |
Sat, 17 Dec 2022 04:57:56 -0500 (EST) |
branch: externals-release/org
commit aa86ed534f93a2b984344b598d679c2e351f049d
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-persist-write-all: Do not create index with no containers
* lisp/org-persist.el (org-persist-write-all): Do not create
`org-persist-directory' when index does not contain any data except
index version.
Link: https://orgmode.org/list/875yedw0ib.fsf@localhost
---
lisp/org-persist.el | 41 +++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 30c5e17d48..f56df9f551 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -881,26 +881,35 @@ When IGNORE-RETURN is non-nil, just return t on success
without calling
When ASSOCIATED is non-nil, only save the matching data."
(unless org-persist--index (org-persist--load-index))
(setq associated (org-persist--normalize-associated associated))
- (let (all-containers)
- (dolist (collection org-persist--index)
- (if associated
- (when collection
- (cl-pushnew (plist-get collection :container) all-containers :test
#'equal))
- (condition-case err
- (org-persist-write (plist-get collection :container) (plist-get
collection :associated) t)
- (error
- (message "%s. Deleting bad index entry." err)
- (org-persist--remove-from-index collection)
- nil))))
- (dolist (container all-containers)
- (let ((collection (org-persist--find-index `(:container ,container
:associated ,associated))))
- (when collection
+ (unless
+ (and (equal 1 (length org-persist--index))
+ ;; The single collection only contains a single container
+ ;; in the container list.
+ (equal 1 (length (plist-get (car org-persist--index) :container)))
+ ;; The container is an `index' container.
+ (eq 'index (caar (plist-get (car org-persist--index) :container)))
+ ;; No `org-persist-directory' exists yet.
+ (not (file-exists-p org-persist-directory)))
+ (let (all-containers)
+ (dolist (collection org-persist--index)
+ (if associated
+ (when collection
+ (cl-pushnew (plist-get collection :container) all-containers
:test #'equal))
(condition-case err
- (org-persist-write container associated t)
+ (org-persist-write (plist-get collection :container) (plist-get
collection :associated) t)
(error
(message "%s. Deleting bad index entry." err)
(org-persist--remove-from-index collection)
- nil)))))))
+ nil))))
+ (dolist (container all-containers)
+ (let ((collection (org-persist--find-index `(:container ,container
:associated ,associated))))
+ (when collection
+ (condition-case err
+ (org-persist-write container associated t)
+ (error
+ (message "%s. Deleting bad index entry." err)
+ (org-persist--remove-from-index collection)
+ nil))))))))
(defun org-persist-write-all-buffer ()
"Call `org-persist-write-all' in current buffer.