Merge branch 'feature/org-persist-new-tidy'
This commit is contained in:
commit
ac5742f296
|
@ -7054,15 +7054,17 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S"
|
|||
|
||||
;;; Cache persistance
|
||||
|
||||
(defun org-element--cache-persist-before-write (var &optional buffer)
|
||||
(defun org-element--cache-persist-before-write (container &optional associated)
|
||||
"Sync cache before saving."
|
||||
(when (and org-element-use-cache
|
||||
buffer
|
||||
org-element-cache-persistent
|
||||
(eq var 'org-element--cache)
|
||||
(derived-mode-p 'org-mode)
|
||||
(when (equal container '(elisp org-element--cache))
|
||||
(if (and org-element-use-cache
|
||||
(plist-get associated :file)
|
||||
(get-file-buffer (plist-get associated :file))
|
||||
org-element-cache-persistent)
|
||||
(with-current-buffer (get-file-buffer (plist-get associated :file))
|
||||
(if (and (derived-mode-p 'org-mode)
|
||||
org-element--cache)
|
||||
(with-current-buffer buffer
|
||||
(progn
|
||||
;; Cleanup cache request keys to avoid collisions during next
|
||||
;; Emacs session.
|
||||
(avl-tree-mapc
|
||||
|
@ -7070,27 +7072,35 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S"
|
|||
(org-element-put-property el :org-element--cache-sync-key nil))
|
||||
org-element--cache)
|
||||
(org-with-wide-buffer
|
||||
(org-element-at-point (point-max))))
|
||||
nil))
|
||||
(org-element-at-point (point-max)))
|
||||
nil)
|
||||
'forbid))
|
||||
'forbid)))
|
||||
|
||||
(defun org-element--cache-persist-before-read (var &optional buffer)
|
||||
(defun org-element--cache-persist-before-read (container &optional associated)
|
||||
"Avoid reading cache before Org mode is loaded."
|
||||
(when (memq var '(org-element--cache org-element--headline-cache))
|
||||
(if (not buffer) 'forbid
|
||||
(with-current-buffer buffer
|
||||
(when (equal container '(elisp org-element--cache))
|
||||
(if (not (and (plist-get associated :file)
|
||||
(get-file-buffer (plist-get associated :file))))
|
||||
'forbid
|
||||
(with-current-buffer (get-file-buffer (plist-get associated :file))
|
||||
(unless (and org-element-use-cache
|
||||
org-element-cache-persistent
|
||||
(derived-mode-p 'org-mode))
|
||||
(derived-mode-p 'org-mode)
|
||||
(equal (secure-hash 'md5 (current-buffer))
|
||||
(plist-get associated :hash)))
|
||||
'forbid)))))
|
||||
|
||||
(defun org-element--cache-persist-after-read (var &optional buffer)
|
||||
(defun org-element--cache-persist-after-read (container &optional associated)
|
||||
"Setup restored cache."
|
||||
(with-current-buffer buffer
|
||||
(when (and (plist-get associated :file)
|
||||
(get-file-buffer (plist-get associated :file)))
|
||||
(with-current-buffer (get-file-buffer (plist-get associated :file))
|
||||
(when (and org-element-use-cache org-element-cache-persistent)
|
||||
(when (and (eq var 'org-element--cache) org-element--cache)
|
||||
(when (and (equal container '(elisp org-element--cache)) org-element--cache)
|
||||
(setq-local org-element--cache-size (avl-tree-size org-element--cache)))
|
||||
(when (and (eq var 'org-element--headline-cache) org-element--headline-cache)
|
||||
(setq-local org-element--headline-cache-size (avl-tree-size org-element--headline-cache))))))
|
||||
(when (and (equal container '(elisp org-element--headline-cache)) org-element--headline-cache)
|
||||
(setq-local org-element--headline-cache-size (avl-tree-size org-element--headline-cache)))))))
|
||||
|
||||
(add-hook 'org-persist-before-write-hook #'org-element--cache-persist-before-write)
|
||||
(add-hook 'org-persist-before-read-hook #'org-element--cache-persist-before-read)
|
||||
|
@ -7115,7 +7125,8 @@ buffers."
|
|||
(when (not org-element-cache-persistent)
|
||||
(org-persist-unregister 'org-element--headline-cache (current-buffer))
|
||||
(org-persist-unregister 'org-element--cache (current-buffer)))
|
||||
(when org-element-cache-persistent
|
||||
(when (and org-element-cache-persistent
|
||||
(buffer-file-name (current-buffer)))
|
||||
(org-persist-register 'org-element--cache (current-buffer))
|
||||
(org-persist-register 'org-element--headline-cache
|
||||
(current-buffer)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -191,7 +191,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-read "org-persist" (var &optional buffer))
|
||||
(declare-function org-persist-load "org-persist" (container &optional associated hash-must-match))
|
||||
(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))
|
||||
|
@ -204,6 +204,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
|
|||
|
||||
(defvar org-agenda-buffer-name)
|
||||
(defvar org-element-paragraph-separate)
|
||||
(defvar org-element-cache-map-continue-from)
|
||||
(defvar org-indent-indentation-per-level)
|
||||
(defvar org-radio-target-regexp)
|
||||
(defvar org-target-link-regexp)
|
||||
|
@ -4881,7 +4882,7 @@ The following commands are available:
|
|||
(org-element-cache-reset)
|
||||
(when (and org-element-cache-persistent
|
||||
org-element-use-cache)
|
||||
(org-persist-read 'org-element--cache (current-buffer)))
|
||||
(org-persist-load 'org-element--cache (current-buffer) t))
|
||||
;; Initialize macros templates.
|
||||
(org-macro-initialize-templates)
|
||||
;; Initialize radio targets.
|
||||
|
|
Loading…
Reference in New Issue