branch: externals/org
commit 1b2d06880f03c4e2063a9c91741935ea49144d2c
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>
org-persist.el: Do not write global variables on buffer kill
* lisp/org-persist.el (org-persist-write-all): Prevent writing global
variables when BUFFER arg is provided.
(org-persist-gc): Handle case when :persist-file is set to nil in the
index.
Fixes
https://list.orgmode.org/db9pr08mb66336cdf0f43de3db1d08649a3...@db9pr08mb6633.eurprd08.prod.outlook.com/T/#m40fcc5ea8ba0ef52518a58713cf9ad3d1fffa33d
---
lisp/org-persist.el | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 47a31e0..fd6fed94 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -209,11 +209,12 @@ When BUFFER is `all', unregister VAR in all buffers."
"Save all the persistent data."
(unless (and buffer (not (buffer-file-name buffer)))
(dolist (index org-persist--index)
- (when (or (not (plist-get index :path))
- (and (get-file-buffer (plist-get index :path))
- (or (not buffer)
- (equal (buffer-file-name buffer)
- (plist-get index :path)))))
+ (when (or (and (not (plist-get index :path))
+ (not buffer))
+ (and (plist-get index :path)
+ (get-file-buffer (plist-get index :path))
+ (equal (buffer-file-name buffer)
+ (plist-get index :path))))
(org-persist-write (plist-get index :variable)
(when (plist-get index :path)
(get-file-buffer (plist-get index :path))))))))
@@ -272,9 +273,10 @@ When BUFFER is `all', unregister VAR in all buffers."
(let (new-index)
(dolist (index org-persist--index)
(let ((file (plist-get index :path))
- (persist-file (org-file-name-concat
- org-persist-directory
- (plist-get index :persist-file))))
+ (persist-file (when (plist-get index :persist-file)
+ (org-file-name-concat
+ org-persist-directory
+ (plist-get index :persist-file)))))
(when (and file persist-file)
(if (file-exists-p file)
(push index new-index)