branch: externals/org
commit 24d155f148fca56b3642711faa500658cf629dc8
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    org-ctrl-c-ctrl-c: Avoid modifying parser cache by side effect
    
    * lisp/org.el (org-ctrl-c-ctrl-c): When modifying list, avoid
    modifying cache by side effect.  If writing fails (e.g. read-only
    buffer), the modified structure in cache will desync with actual
    buffer contents.
    
    Reported-by: Mike Kupfer <kup...@rawbw.com>
    Link: https://orgmode.org/list/120667.1742955...@alto.camomileplus.org
---
 lisp/org.el | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 78e8c06922..9dcf103215 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17917,6 +17917,8 @@ This command does many different things, depending on 
context:
             (org-toggle-radio-button arg)
           (let* ((box (org-element-property :checkbox context))
                  (struct (org-element-property :structure context))
+                  ;; Avoid modifying cached structure by side effect.
+                  (struct (copy-tree struct))
                  (old-struct (copy-tree struct))
                  (parents (org-list-parents-alist struct))
                  (prevs (org-list-prevs-alist struct))
@@ -17960,6 +17962,8 @@ This command does many different things, depending on 
context:
             (org-toggle-radio-button arg)
           (let* ((begin (org-element-contents-begin context))
                  (struct (org-element-property :structure context))
+                  ;; Avoid modifying cached structure by side effect.
+                  (struct (copy-tree struct))
                  (old-struct (copy-tree struct))
                  (first-box (save-excursion
                               (goto-char begin)

Reply via email to