forked from mirrors/org-mode
org-persist-write:elisp: Allow buffer-local/global elisp container scope
* lisp/org-persist.el (org-persist-read:index): Allow setting where the elisp container value is taken from: locally, from buffer, or from a global variable.
This commit is contained in:
parent
f8428d0f3e
commit
ffec2db731
|
@ -632,16 +632,29 @@ COLLECTION is the plist holding data collection."
|
||||||
|
|
||||||
(defun org-persist-write:elisp (container collection)
|
(defun org-persist-write:elisp (container collection)
|
||||||
"Write elisp CONTAINER according to COLLECTION."
|
"Write elisp CONTAINER according to COLLECTION."
|
||||||
(if (and (plist-get (plist-get collection :associated) :file)
|
(let ((scope (nth 2 container)))
|
||||||
(get-file-buffer (plist-get (plist-get collection :associated) :file)))
|
(pcase scope
|
||||||
(let ((buf (get-file-buffer (plist-get (plist-get collection :associated) :file))))
|
((pred stringp)
|
||||||
;; FIXME: There is `buffer-local-boundp' introduced in Emacs 28.
|
(when-let ((buf (or (get-buffer scope)
|
||||||
;; Not using it yet to keep backward compatibility.
|
(get-file-buffer scope))))
|
||||||
(condition-case nil
|
;; FIXME: There is `buffer-local-boundp' introduced in Emacs 28.
|
||||||
(buffer-local-value (cadr container) buf)
|
;; Not using it yet to keep backward compatibility.
|
||||||
(void-variable nil)))
|
(condition-case nil
|
||||||
(when (boundp (cadr container))
|
(buffer-local-value (cadr container) buf)
|
||||||
(symbol-value (cadr container)))))
|
(void-variable nil))))
|
||||||
|
(`local
|
||||||
|
(when (boundp (cadr container))
|
||||||
|
(symbol-value (cadr container))))
|
||||||
|
(`nil
|
||||||
|
(if-let ((buf (and (plist-get (plist-get collection :associated) :file)
|
||||||
|
(get-file-buffer (plist-get (plist-get collection :associated) :file)))))
|
||||||
|
;; FIXME: There is `buffer-local-boundp' introduced in Emacs 28.
|
||||||
|
;; Not using it yet to keep backward compatibility.
|
||||||
|
(condition-case nil
|
||||||
|
(buffer-local-value (cadr container) buf)
|
||||||
|
(void-variable nil))
|
||||||
|
(when (boundp (cadr container))
|
||||||
|
(symbol-value (cadr container))))))))
|
||||||
|
|
||||||
(defalias 'org-persist-write:version #'ignore)
|
(defalias 'org-persist-write:version #'ignore)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue