From 00f44f46f65a96bb84271faa7f4ed7965fc44d5e Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 30 Jul 2026 17:48:06 -0500 Subject: docs: keep the org-element cache reproduction evidence Twelve scripts plus a README covering the persist-write cache corruption: the no-dirvish root cause, the buffer-list ordering dependency, a faithful replay of the file-manager preview path, and the two fixes I tried and reverted. The README says which scripts are weak evidence and why, so the next reader doesn't rebuild an argument on the one whose control varied three things at once. Also holds the upstream bug report and its reproduction, verified to run standalone under emacs -Q. --- .../hostile-d-nopreview.el | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 working/org-element-cache-persist-bug/hostile-d-nopreview.el (limited to 'working/org-element-cache-persist-bug/hostile-d-nopreview.el') diff --git a/working/org-element-cache-persist-bug/hostile-d-nopreview.el b/working/org-element-cache-persist-bug/hostile-d-nopreview.el new file mode 100644 index 00000000..91ae1ce7 --- /dev/null +++ b/working/org-element-cache-persist-bug/hostile-d-nopreview.el @@ -0,0 +1,23 @@ +(require 'cl-lib) (require 'org) (require 'org-element) (require 'org-persist) +(setq org-element-use-cache t org-element-cache-persistent t) +(when (getenv "SV") (setq org-element--cache-self-verify t org-element--cache-self-verify-frequency 1.0)) +(defun nilbuf (buf) (with-current-buffer buf + (let ((k 0)) (avl-tree-mapc (lambda (el) (unless (org-element-property :buffer el) (cl-incf k))) org-element--cache) k))) +(let* ((file (make-temp-file "np-" nil ".org"))) + (copy-file (expand-file-name "todo.org" default-directory) file t) + (let ((real (find-file-noselect file))) + (with-current-buffer real (org-element-cache-map (lambda (_) nil) :granularity 'element)) + (message ">> before: nil-buffer=%d" (nilbuf real)) + (message ">> MODE=%s" (getenv "MODE")) + (pcase (getenv "MODE") + ("writeall" (org-persist-write-all)) + ("writebuf" (with-current-buffer real (org-persist-write-all-buffer))) + (_ nil)) + (message ">> after trigger: nil-buffer=%d" (nilbuf real)) + (with-current-buffer real + (goto-char (point-max)) + (condition-case err (let ((inhibit-read-only t)) (insert "\n* Edit\n")) + (error (message ">> RESULT: insert SIGNALLED %S" err))) + (message ">> insert survived (nil-buffer=%d)" (nilbuf real)) + (set-buffer-modified-p nil))) + (delete-file file)) -- cgit v1.2.3