[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org a97b378ee5 4/9: org-persist-read: Do not return rel
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org a97b378ee5 4/9: org-persist-read: Do not return related containers by default |
Date: |
Thu, 29 Dec 2022 04:58:03 -0500 (EST) |
branch: externals/org
commit a97b378ee50fa2b38069f05da2a27f0439aae76b
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-persist-read: Do not return related containers by default
* lisp/org-persist.el (org-persist-read): Only return the requested
containers. Add new optional keyword argument :read-related to read
the containers stored together with requested. Update the docstring
accordingly.
(org-persist-load): Update definition according to `org-persist-read'.
* lisp/org.el (org-mode): Explicitly load all the associated
cache variables.
---
lisp/org-persist.el | 38 +++++++++++++++++++++++++++-----------
lisp/org.el | 4 ++--
2 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 60088af9ee..aee2070319 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -822,14 +822,27 @@ When ASSOCIATED is `all', unregister CONTAINER
everywhere."
"Hash table storing as-written data objects.
This data is used to avoid reading the data multiple times.")
-(defun org-persist-read (container &optional associated hash-must-match load?)
+(cl-defun org-persist-read (container &optional associated hash-must-match
load &key read-related)
"Restore CONTAINER data for ASSOCIATED.
When HASH-MUST-MATCH is non-nil, do not restore data if hash for
ASSOCIATED file or buffer does not match.
+
ASSOCIATED can be a plist, a buffer, or a string.
A buffer is treated as (:buffer ASSOCIATED).
A string is treated as (:file ASSOCIATED).
-When LOAD? is non-nil, load the data instead of reading."
+
+When LOAD is non-nil, load the data instead of reading.
+
+When READ-RELATED is non-nil, return the data stored alongside with
+CONTAINER as well. For example:
+
+ (let ((info \"test\"))
+ (org-persist-register
+ \\='((version \"My data\") (elisp info local))
+ nil :write-immediately t))
+ (org-persist-read \\='(version \"My data\")) ; => \"My data\"
+ (org-persist-read \\='(version \"My data\")
+ :read-related t) ; => (\"My data\" \"test\")"
(unless org-persist--index (org-persist--load-index))
(setq associated (org-persist--normalize-associated associated))
(setq container (org-persist--normalize-container container))
@@ -859,19 +872,22 @@ When LOAD? is non-nil, load the data instead of reading."
(setq data (or (gethash persist-file org-persist--write-cache)
(org-persist--read-elisp-file persist-file)))
(when data
- (cl-loop for container in (plist-get collection :container)
+ (cl-loop for c in (plist-get collection :container)
with result = nil
do
- (if load?
- (push (org-persist-load:generic container (alist-get
container data nil nil #'equal) collection) result)
- (push (org-persist-read:generic container (alist-get
container data nil nil #'equal) collection) result))
- (run-hook-with-args 'org-persist-after-read-hook container
associated)
- finally return (if (= 1 (length result)) (car result)
result)))))))
-
-(defun org-persist-load (container &optional associated hash-must-match)
+ (when (or read-related
+ (equal c container)
+ (member c container))
+ (if load
+ (push (org-persist-load:generic c (alist-get c data
nil nil #'equal) collection) result)
+ (push (org-persist-read:generic c (alist-get c data nil
nil #'equal) collection) result)))
+ (run-hook-with-args 'org-persist-after-read-hook c
associated)
+ finally return (if (= 1 (length result)) (car result)
(nreverse result))))))))
+
+(cl-defun org-persist-load (container &optional associated hash-must-match
&key read-related)
"Load CONTAINER data for ASSOCIATED.
The arguments have the same meaning as in `org-persist-read'."
- (org-persist-read container associated hash-must-match t))
+ (org-persist-read container associated hash-must-match t :read-related
read-related))
(defun org-persist-load-all (&optional associated)
"Restore all the persistent data associated with ASSOCIATED."
diff --git a/lisp/org.el b/lisp/org.el
index 26a4c8b1c6..6906881608 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -206,7 +206,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
(declare-function org-latex-make-preamble "ox-latex" (info &optional template
snippet?))
(declare-function org-num-mode "org-num" (&optional arg))
(declare-function org-plot/gnuplot "org-plot" (&optional params))
-(declare-function org-persist-load "org-persist" (container &optional
associated hash-must-match))
+(declare-function org-persist-load "org-persist")
(declare-function org-tags-view "org-agenda" (&optional todo-only match))
(declare-function org-timer "org-timer" (&optional restart no-insert))
(declare-function org-timer-item "org-timer" (&optional arg))
@@ -4839,7 +4839,7 @@ The following commands are available:
(org-element-cache-reset)
(when (and org-element-cache-persistent
org-element-use-cache)
- (org-persist-load 'org-element--cache (current-buffer) t))
+ (org-persist-load 'org-element--cache (current-buffer) 'match-hash
:read-related t))
;; Initialize macros templates.
(org-macro-initialize-templates)
;; Initialize radio targets.
- [elpa] externals/org updated (5549357bf2 -> a9c0d4cde2), ELPA Syncer, 2022/12/29
- [elpa] externals/org e8cb52bd3e 1/9: org-persist-read: Attempt to write newly register data before reading, ELPA Syncer, 2022/12/29
- [elpa] externals/org f8428d0f3e 2/9: org-fold-core--isearch-show: Small refactoring, ELPA Syncer, 2022/12/29
- [elpa] externals/org 14bfe2841c 5/9: org-persist: Use `list-data-mode' for stored data, ELPA Syncer, 2022/12/29
- [elpa] externals/org 13e78df46a 6/9: * lisp/org-persist.el: Update commentary, ELPA Syncer, 2022/12/29
- [elpa] externals/org a97b378ee5 4/9: org-persist-read: Do not return related containers by default,
ELPA Syncer <=
- [elpa] externals/org ffec2db731 3/9: org-persist-write:elisp: Allow buffer-local/global elisp container scope, ELPA Syncer, 2022/12/29
- [elpa] externals/org b86989c8df 8/9: Merge branch 'bugfix', ELPA Syncer, 2022/12/29
- [elpa] externals/org a9c0d4cde2 9/9: org-occur-in-agenda-files: Respect agenda restriction, ELPA Syncer, 2022/12/29
- [elpa] externals/org dedf1cc21f 7/9: org-persist: Add more normalizations and new `elisp-data' container, ELPA Syncer, 2022/12/29