branch: externals/org commit 09f339c9dd0360fc430c2f6d7d611c3c6128dc36 Author: Ihor Radchenko <yanta...@posteo.net> Commit: Ihor Radchenko <yanta...@posteo.net>
org-element-cache: Fix tracking changes in indirect buffers for overlay folding * lisp/org-fold-core.el (org-fold-core-decouple-indirect-buffer-folds): (org-fold-core--property-symbol-get-create): Make `org-fold-core-cycle-over-indirect-buffers' track indirect buffers even with `org-fold-core-style' = 'overlays. This is necessary to keep org-element-cache working. * lisp/org-element.el: Add FIXME - we should eventually pull out `org-fold-core-cycle-over-indirect-buffers' as it is used out of scope of folding. --- lisp/org-element.el | 2 ++ lisp/org-fold-core.el | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 071be1dd1e..92a007bac6 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -6147,6 +6147,8 @@ This function assumes `org-element--headline-cache' is a valid AVL tree." ;;;; Tools +;; FIXME: `org-fold-core-cycle-over-indirect-buffers' should better be +;; taken out of org-fold-core to track indirect buffers in general. (defun org-element--cache-active-p (&optional called-from-cache-change-func-p) "Non-nil when cache is active in current buffer. When CALLED-FROM-CACHE-CHANGE-FUNC-P is non-nil, do not assert cache diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el index 8e919d8895..664846a619 100644 --- a/lisp/org-fold-core.el +++ b/lisp/org-fold-core.el @@ -581,15 +581,6 @@ unless RETURN-ONLY is non-nil." ;; would contain folding properties, which are not ;; matching the generated `local-prop'. (unless (member local-prop (cdr (assq 'invisible char-property-alias-alist))) - ;; Add current buffer to the list of indirect buffers in the base buffer. - (when (buffer-base-buffer) - (with-current-buffer (buffer-base-buffer) - (setq-local org-fold-core--indirect-buffers - (let (bufs) - (org-fold-core-cycle-over-indirect-buffers - (push (current-buffer) bufs)) - (push buf bufs) - (delete-dups bufs))))) ;; Copy all the old folding properties to preserve the folding state (with-silent-modifications (dolist (old-prop (cdr (assq 'invisible char-property-alias-alist))) @@ -648,6 +639,15 @@ unless RETURN-ONLY is non-nil." "Copy and decouple folding state in a newly created indirect buffer. This function is mostly intended to be used in `clone-indirect-buffer-hook'." + ;; Add current buffer to the list of indirect buffers in the base buffer. + (when (buffer-base-buffer) + (with-current-buffer (buffer-base-buffer) + (setq-local org-fold-core--indirect-buffers + (let (bufs) + (org-fold-core-cycle-over-indirect-buffers + (push (current-buffer) bufs)) + (push (current-buffer) bufs) + (delete-dups bufs))))) (when (and (buffer-base-buffer) (eq org-fold-core-style 'text-properties) (not (memql 'ignore-indirect org-fold-core--optimise-for-huge-buffers)))