org-persist.el/org-persist-write: Do not write when no write access

This commit is contained in:
Ihor Radchenko 2021-10-19 20:10:27 +08:00
parent 46da64c4cf
commit 2b33ef3c97
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 10 additions and 9 deletions

View File

@ -186,15 +186,16 @@ When BUFFER is `all', unregister VAR in all buffers."
(unless (file-writable-p dir)
(message "Missing write access rights to org-persist-directory: %S"
org-persist-directory))))
(with-temp-file (org-file-name-concat org-persist-directory org-persist-index-file)
(prin1 org-persist--index (current-buffer)))
(let ((file (org-file-name-concat org-persist-directory (plist-get index :persist-file)))
(data (mapcar (lambda (s) (cons s (symbol-value s)))
(plist-get index :variable))))
(unless (file-exists-p (file-name-directory file))
(make-directory (file-name-directory file) t))
(with-temp-file file
(prin1 data (current-buffer))))))))))
(when (file-exists-p org-persist-directory)
(with-temp-file (org-file-name-concat org-persist-directory org-persist-index-file)
(prin1 org-persist--index (current-buffer)))
(let ((file (org-file-name-concat org-persist-directory (plist-get index :persist-file)))
(data (mapcar (lambda (s) (cons s (symbol-value s)))
(plist-get index :variable))))
(unless (file-exists-p (file-name-directory file))
(make-directory (file-name-directory file) t))
(with-temp-file file
(prin1 data (current-buffer)))))))))))
(defun org-persist-write-all (&optional buffer)
"Save all the persistent data."