Skip to content

Commit

Permalink
org-export: Suppress cache persistence in buffer copies during export
Browse files Browse the repository at this point in the history
* lisp/org-element.el (org-element-cache-reset): Add new optional
argument that suppresses all persistence-related calculations.
* lisp/org-table.el (org-element-cache-reset):
* lisp/org.el (org-element-cache-reset): Update function signature.
* lisp/ox.el (org-export--generate-copy-script): Do not try to use
cache persistence in throwaway buffer copies.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://list.orgmode.org/m2zgef774u.fsf@me.com/T/#t
  • Loading branch information
yantar92 committed Oct 7, 2022
1 parent 09fd5f8 commit 514e3a9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions lisp/org-element.el
Original file line number Diff line number Diff line change
Expand Up @@ -7238,16 +7238,18 @@ Each element indicates the latest `org-element--cache-change-tic' when
change did not contain gaps.")

;;;###autoload
(defun org-element-cache-reset (&optional all)
(defun org-element-cache-reset (&optional all no-persistance)
"Reset cache in current buffer.
When optional argument ALL is non-nil, reset cache in all Org
buffers."
buffers.
When optional argument NO-PERSISTANCE is non-nil, do not try to update
the cache persistence in the buffer."
(interactive "P")
(dolist (buffer (if all (buffer-list) (list (current-buffer))))
(with-current-buffer (or (buffer-base-buffer buffer) buffer)
(when (and org-element-use-cache (derived-mode-p 'org-mode))
;; Only persist cache in file buffers.
(when (buffer-file-name)
(when (and (buffer-file-name) (not no-persistance))
(when (not org-element-cache-persistent)
(org-persist-unregister 'org-element--headline-cache (current-buffer))
(org-persist-unregister 'org-element--cache (current-buffer)))
Expand Down
2 changes: 1 addition & 1 deletion lisp/org-table.el
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
(declare-function org-element-property "org-element" (property element))
(declare-function org-element-type "org-element" (element))
(declare-function org-element-cache-reset "org-element" (&optional all))
(declare-function org-element-cache-reset "org-element" (&optional all no-persistence))
(declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
(declare-function org-export-create-backend "ox" (&rest rest) t)
(declare-function org-export-data-with-backend "ox" (data backend info))
Expand Down
2 changes: 1 addition & 1 deletion lisp/org.el
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
(declare-function org-element-at-point-no-context "org-element" (&optional pom))
(declare-function org-element-cache-refresh "org-element" (pos))
(declare-function org-element-cache-reset "org-element" (&optional all))
(declare-function org-element-cache-reset "org-element" (&optional all no-persistence))
(declare-function org-element-cache-map "org-element" (func &rest keys))
(declare-function org-element-contents "org-element" (element))
(declare-function org-element-context "org-element" (&optional element))
Expand Down
2 changes: 1 addition & 1 deletion lisp/ox.el
Original file line number Diff line number Diff line change
Expand Up @@ -2671,7 +2671,7 @@ The function assumes BUFFER's major mode is `org-mode'."
(when str (erase-buffer) (insert str))
;; Make org-element-cache not complain about changed buffer
;; state.
(org-element-cache-reset)
(org-element-cache-reset nil 'no-persistence)
;; Narrowing.
(when narrowing
(apply #'narrow-to-region narrowing))
Expand Down

0 comments on commit 514e3a9

Please sign in to comment.