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/DB9PR08MB66336CDF0F43DE3DB1D08649A3869@DB9PR08MB6633.eurprd08.prod.outlook.com/T/#m40fcc5ea8ba0ef52518a58713cf9ad3d1fffa33d
This commit is contained in:
parent
5abd149cf1
commit
1b2d06880f
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue