[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org ccb0271 6/6: org-persist.el: Do not add write hooks
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org ccb0271 6/6: org-persist.el: Do not add write hooks when there is no write access |
Date: |
Tue, 19 Oct 2021 08:57:26 -0400 (EDT) |
branch: externals/org
commit ccb0271e1a362c10d4992421a5e11f70f1c288cd
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org-persist.el: Do not add write hooks when there is no write access
---
lisp/org-persist.el | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 55c6368..b017be1 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -278,8 +278,18 @@ When BUFFER is `all', unregister VAR in all buffers."
(delete-directory (file-name-directory persist-file))))))))
(setq org-persist--index (nreverse new-index))))
-(add-hook 'kill-emacs-hook #'org-persist-gc)
-(add-hook 'kill-emacs-hook #'org-persist-write-all 100)
+;; Automatically write the data, but only when we have write access.
+(let ((dir (directory-file-name
+ (file-name-as-directory org-persist-directory))))
+ (while (and (not (file-exists-p dir))
+ (not (equal dir (setq dir (directory-file-name
+ (file-name-directory dir)))))))
+ (if (not (file-writable-p dir))
+ (message "Missing write access rights to org-persist-directory: %S"
+ org-persist-directory)
+ (add-hook 'kill-emacs-hook #'org-persist-gc)
+ (add-hook 'kill-emacs-hook #'org-persist-write-all 100)))
+
(add-hook 'after-init-hook #'org-persist-read-all)
(provide 'org-persist)
- [elpa] externals/org updated (7810804 -> ccb0271), ELPA Syncer, 2021/10/19
- [elpa] externals/org 3b48224 1/6: org-persist.el: Rename `org-persist-path' to `org-persist-directory', ELPA Syncer, 2021/10/19
- [elpa] externals/org bad854d 2/6: org-persist.el: Catch write errors, ELPA Syncer, 2021/10/19
- [elpa] externals/org c130f71 3/6: org-persist.el: Fix typo, ELPA Syncer, 2021/10/19
- [elpa] externals/org 46da64c 4/6: org-persist.el: Fix `add-hook' priority argument, ELPA Syncer, 2021/10/19
- [elpa] externals/org 2b33ef3 5/6: org-persist.el/org-persist-write: Do not write when no write access, ELPA Syncer, 2021/10/19
- [elpa] externals/org ccb0271 6/6: org-persist.el: Do not add write hooks when there is no write access,
ELPA Syncer <=